shithub: MicroHs

Download patch

ref: 089ead198791e82cd2cebef573a7ca6e2474503d
parent: 6f407c9a20b6d09d00e6ad9747f1dabfd535deb5
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Sun Aug 20 10:17:56 EDT 2023

Update docs

--- a/README.md
+++ b/README.md
@@ -5,17 +5,18 @@
 The compiler can compile itself.
 
 ## Language
-The language is a subset of Haskell.  There is no static type checking (yet).
+The language is a subset of Haskell.  There is only simple Hindley-Milner overloading,
+no type classes.
 
 It has the following features:
 * variables
 * application
-* lambda, just variables, not pattern matching
+* lambda
 * integer literals
 * character literals
 * string (list of characters) literals
-* case expressions, no nested patterns, must be exhaustive
-* let expressions, no mutual recursion, no pattern matching
+* case expressions
+* let expressions, no mutual recursion
 * tuples
 * list syntax
 * list comprehensions
@@ -22,9 +23,10 @@
 * arithmetic and comparison operators, but only for `Int`
 * qualified `do` notation, e.g., `IO.do`
 * data type declarations
-* type signatures that are ignored
+* type synonyms
+* type signatures
 * importing of other modules, `qualified` and `as` supported, but no import list
-* exporting with mandatory export list, only module exports allowed
+* exporting with mandatory export list
 * the `Prelude` has to be imported explicitely
 
 ## Example
@@ -33,11 +35,11 @@
 module Example(module Example) where
 import Prelude
 
-fac n =
-  case n <= 0 of
-    True  -> 1
-    False -> n * fac(n-1)
+fac :: Int -> Int
+fac 0 = 1
+fac n = n * fac(n-1)
 
+main :: IO ()
 main = do
   let
     rs = map fac [1,2,3,10]
@@ -46,7 +48,7 @@
 ```
 
 First, make sure the binaries are built.  E.g., by doing `make test`.
-Then compile the file by `bin/uhs -ilib Example` which produces `out.comb`.
+Then compile the file by `bin/mhs -ilib Example` which produces `out.comb`.
 Finally, run the combinator file by `bin/eval out.comb`.
 This should produce
 ```
@@ -63,7 +65,10 @@
 It takes a name of a module and compiles it to a file called `out.comb`.
 
 ### Compiler flags
-TBD
+* `-iDIR` add `DIR` to search path for modules
+* `-oFILE` output combinators to `FILE` instead of `out.comb`
+* `-r` run directly, does work if compiled with GHC
+* `-v` be more verbose, flag can be repeated
 
 ### Compiler modules
 
@@ -74,6 +79,7 @@
 * `Parse`, parse and build and abstract syntax tree.
 * `ParserComb`, simple parser combinator library.
 * `Translate`, convert an expression tree to its value.
+* `TypeCheck`, type checker
 
 ## Runtime
 The runtime system is written in C and is in `eval.c`.
@@ -81,10 +87,24 @@
 for integers and for executing IO operations.
 There is a also a simple mark-scan garbage collector.
 
+### Runtime flags
+* `-HSIZE` set heap size to `SIZE` cells, can be suffixed by `k`, `M`, or `G`
+* `-KSIZE` set stack size to `SIZE` entries, can be suffixed by `k`, `M`, or `G`
+* `-rFILE` read combinators from `FILE`
+* `-v` be more verbose, flag can be repeated.
+* `--` end of flags, the rest of the arguments are available to the running program
+
 ### Features
 The runtime system can serialize and deserialize any expression
 and keep its graph structure (sharing and cycles).
 The only exception to this is file handles, which cannot be serialized.
 
-### Runtime flags
-TBD
+## Bootstrapping
+It is possible to recompile the compiler without access to a Haskell compiler.
+The combinator file for the compiler itself is available in `comb/mhs.comb`.
+To bootstrap:
+ * build the evaluator `make bin/eval`, this requires a C compiler
+ * compiler the compiler
+```
+bin/eval -H50M -rcomb/mhs.comb -- -ilib -isrc -onewmhs.comb MicroHs.Main
+```
--