MicroHs: A small compiler for Haskell

[ apache, language, program ] [ Propose Tags ] [ Report a vulnerability ]

A compiler for an extended subset of Haskell-2010. The compiler translates to combinators and can compile itself.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.8, 0.8.1.0, 0.8.2.0, 0.8.2.1, 0.8.2.2, 0.8.3.0, 0.8.4.0, 0.8.5.0, 0.9.1.0, 0.9.2.0, 0.9.3.0, 0.9.5.0, 0.9.8.0, 0.9.11.0, 0.9.12.0, 0.9.13.0, 0.9.14.0, 0.9.15.0, 0.9.16.0, 0.9.17.0, 0.9.18.0, 0.10.3.0, 0.10.4.0, 0.10.4.1, 0.10.5.0, 0.10.7.0, 0.11.4.0, 0.12.6.1, 0.13.0.0, 0.15.0.0, 0.16.0.0, 0.17.4.0
Dependencies array (>=0.5 && <0.6), base (>=0.1 && <99.9), bytestring (>=0.5 && <0.20), deepseq (>=1.1 && <1.8), directory (>=1.2 && <1.6), filepath (>=1.1 && <1.8), haskeline (>=0.8 && <0.10), process (>=1.6 && <1.10), text (>=2.0 && <2.5), time (>=1.9 && <1.20) [details]
License Apache-2.0
Copyright 2023-2026 Lennart Augustsson
Author lennart@augustsson.net
Maintainer lennart@augustsson.net
Uploaded by LennartAugustsson at 2026-12-03T18:10:03Z
Category language
Source repo head: git clone https://github.com/augustss/MicroHs
Distributions
Executables mhs
Downloads 2040 total (51 in the last 30 days)
Rating 2.5 (votes: 3) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2026-12-03 [all 1 reports]

Readme for MicroHs-0.17.4.0

[back to package description]

Micro Haskell

MicroHs (mhs) is a compiler for an extended subset of Haskell 2010, with many GHC extensions. It compiles to combinators that are executed by a small, portable runtime system written in C. The compiler can compile itself, and all you need to build it is a C compiler; no Haskell compiler is required. The runtime is small enough to run on micro-controllers.

Try it in your browser.

Installing

git clone --depth=1 https://github.com/augustss/MicroHs.git
cd MicroHs
make install

This installs mhs, cpphs, and mcabal (for installing packages) in ~/.mcabal/bin, together with the compiled base package. Add ~/.mcabal/bin to your PATH.

On Windows, make sure cl is in the path and use nmake -f Makefile.windows install.

Example

The file Example.hs contains:

module Example(fac, main) where

fac :: Integer -> Integer
fac 0 = 1
fac n = n * fac(n - 1)

main :: IO ()
main = do
  let rs = map fac [1,2,3,10,52]
  putStrLn "Some factorials"
  print rs

Compile and run it:

$ mhs Example -oEx
$ ./Ex
Some factorials
[1,2,6,3628800,80658175170943878571660636856403766975289505440883277824000000000000]

Running mhs with no arguments starts an interactive session.

Documentation

The full documentation is in doc/MicroHs.md.

There are some slides with a general presentation of MicroHs.

There is also a presentation from the Haskell Symposium 2024 (video) and a short paper, doc/hs2024.pdf.