shithub: MicroHs

Download patch

ref: 766bc6f2cf7fe1d3413cad35d97db6f3f9b98492
parent: 0fe3f973d0c473053666bb0534d0153fc2d70dbf
author: Rewbert <krookr@chalmers.se>
date: Mon Sep 25 10:32:26 EDT 2023

my editor inserted changes of its own into the README, here I try to undo some of them

--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
 # Micro Haskell
-
 This directory contains an implementation of a small subset of Haskell.
 It uses combinators for the runtime execution.
 
@@ -6,7 +5,6 @@
 The compiler can compile itself.
 
 ## Compiling MicroHs
-
 There are three different ways to compile MicroHs
 
 * Using GHC with standard `Prelude` and libraries. `Makefile` target `bin/mhs`
@@ -26,7 +24,6 @@
 All you need is a C compiler, and MicroHs can bootstrap, given the included combinator file (`comb/mhs.comb`).
 
 ## Language
-
 The language is a subset of Haskell.  There is only simple Hindley-Milner polymorphism,
 no type classes (yet).
 
@@ -56,9 +53,7 @@
 * terrible error messages, some errors are not even flagged
 
 ## Example
-
 The file `Example.hs` contains the following:
-
 ```Haskell
 module Example(main) where
 import Prelude
@@ -79,7 +74,6 @@
 Then compile the file by `bin/mhs -ilib Example` which produces `out.comb`.
 Finally, run the combinator file by `bin/eval`.
 This should produce
-
 ```
 Some factorials
 [1,2,6,3628800]
@@ -86,12 +80,10 @@
 ```
 
 ## Libraries
-
 There are a number of libraries that have some of the standard Haskell functions.
 But in general, the `Prelude` contains much, much less.
 
 ## Types
-
 There are some primitive data types, e.g `Int`, `Handle`, and `Double`.  These are known by the runtime system and various primitive operations work on them.  The function type, `->`, is (of course) also built in. The support for rendering (printing) `Double`s is a bit primitive, and only at most 6 decimal places will be shown. The actual value can contain more precise values, however.
 
 All other types are defined with the language.  They are converted to lambda terms using
@@ -98,12 +90,10 @@
 the Scott encoding.   The runtime system knows how lists are encoded and booleans are encoded.
 
 ## Compiler
-
 The compiler is written in Micro Haskell.
 It takes a name of a module and compiles it to a file called `out.comb`.
 
 ### Compiler flags
-
 * `-iDIR` add `DIR` to search path for modules
 * `-oFILE` output combinators to `FILE` instead of `out.comb`
 * `-r` run directly, does not work if compiled with GHC
@@ -111,16 +101,14 @@
 
 With the `-v` flag the processing time for each module is reported.
 E.g.
-
-```
+  ```
   importing done MicroHs.Exp, 716ms (368 + 348)
-```
+  ```
 
 which means tha processing `MicroHs.Exp.hs` took 716ms,
 with parsing taking 368ms and typecheck&desugar taking 348ms.
 
 ### Compiler modules
-
 * `Main`, the main module.  Decodes flags, compiles, and writes result.
 * `Compile`, top level compiler.  Maintains a cache of already compiled modules.
 * `Exp`, simple expression type, combinator abstraction and optimization.
@@ -132,7 +120,6 @@
 * `TypeCheck`, type checker.
 
 ## Interactive mode
-
 If no module name is given the compiler enters interactive mode.
 You can enter expressions to be evaluated, or top level definitions.
 Simple line editing is available.
@@ -155,7 +142,6 @@
 This is a bug.
 
 ## Runtime
-
 The runtime system is written in C and is in `eval.c`.
 It uses combinators for handling variables, and has primitive operations
 for integers and for executing IO operations.
@@ -163,13 +149,12 @@
 It is written in a reasonably portable C code.
 
 ### Runtime flags
-
 Runtime flags are given between the flags `+RTS` and `-RTS`.
 Between those the runtime decodes the flags, everything else is available to
 the running program.
 
 * `-HSIZE` set heap size to `SIZE` cells, can be suffixed by `k`, `M`, or `G`, default is `50M`
-* `-KSIZE` set stack size to `SIZE` entries, can be suffixed by `k`, `M`, or `G`, default is `100k`
+* `-KSIZE` set stack size to `SIZE` entries, can be suffixed by `k`, `M`, or `G`, default is`100k`
 * `-rFILE` read combinators from `FILE`, instead of `out.comb`
 * `-v` be more verbose, flag can be repeated
 
@@ -177,13 +162,11 @@
 whereas the runtime system sets the heap to 1M cells and is verbose.
 
 ### 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 (except for `stdin`, `stdout`, and `stderr`).
 
 ### Memory layout
-
 Memory allocation is based on cells.  Each cell has room for two pointers (i.e., two words, i.e., 16 bytes),
 so it can represent an application node.  One bit is used to indicate if
 the cell has an application or something else.  If it is something else one
@@ -200,7 +183,6 @@
 This has a performance penalty, though.
 
 ### Portability
-
 The C code for the evaluator does not use any special features, and should be
 portable to many platforms.  It has mostly been test with MacOS and Linus,
 so there are undoubtedly problems on Windows.
@@ -209,37 +191,38 @@
 with other word sizes.
 
 ## 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`.
 The bootstrapping process takes about 20s (on a modern machine).
 To bootstrap:
-
-* build the evaluator, `make bin/eval`, this requires a C compiler
-* compile the compiler
+ * build the evaluator, `make bin/eval`, this requires a C compiler
+ * compile the compiler
   ```
   bin/eval +RTS -rcomb/mhs.comb -RTS -ilib -isrc -onewmhs.comb MicroHs.Main
   ```
-* The file `newmhs.comb` is the new combinator binary and it should be
-  identical to `comb/mhs.comb`.
-* It is also possible to bake the combinator code into the binary.
-  See `make` target `bin/cmhs` for how it is done.
-* For systems where `upx` works you can further compress
-  the binary.  See `bin/umhs` target.
+ * The file `newmhs.comb` is the new combinator binary and it should be
+   identical to `comb/mhs.comb`.
+ * It is also possible to bake the combinator code into the binary.
+   See `make` target `bin/cmhs` for how it is done.
+ * For systems where `upx` works you can further compress
+   the binary.  See `bin/umhs` target.
 
 **NOTE** The GC mark phase currently uses a ridiculously deep stack.
 You might have to increase it on your system.
 
 # FAQ
-
-* * Q: When will it get _insert feature_?
+*
+  * Q: When will it get _insert feature_?
   * A: Maybe some time, maybe never.
-* * Q: Why are the error messages so bad?
+*
+  * Q: Why are the error messages so bad?
   * A: Error messages are boring.
-* * Q: Why is the so much source code?
+*
+  * Q: Why is the so much source code?
   * A: I wonder this myself.  Over 5000 lines of Haskell seems excessive.
     2000 lines of C is also more than I'd like for such a simple system.
-* * Q: Why are the binaries so big?
+*
+  * Q: Why are the binaries so big?
   * A: The combinator file is rather verbose.  The combinator file
     for the compiler shrinks from 170kB to 30kB when compressed.
     The evaluator is about 60kB.
--