Cupid is a small Haskell interpreter written in C, descended from
Hugs, and short
enough to read.
$ cupid
Cupid> let fibs = 0 : 1 : zipWith (+) fibs (tail fibs) in takeWhile (< 100) fibs
[0,1,1,2,3,5,8,13,21,34,55,89]
Cupid> :type sum
sum :: (Foldable a, Num b) => a b -> b
Cupid> sum (Just 3)
3
Cupid> fmap (* 2) (Just 21)
Just 42
Cupid implements Haskell 2010, with
documented deviations,
and a fixed set of
extensions,
almost all always on. These include multi-parameter type classes, functional
dependencies, rank-2 and existential types and GADT syntax. Its libraries are a
subset of GHC’s base,
roughly version 4.18. It has no type families, no type refinement from
GADTs and no Template Haskell.
On Linux or macOS:
curl -fsSL https://andreabedini.github.io/cupid/install.sh | sh
The interpreter is under fifty thousand lines of C. Every run takes source text
through a lexer, a parser, static analysis, a type checker and a compiler to the
code of a small abstract machine. There is no optimising pass and no object code.