U.hs is a LISP syntax Unlambda implementation written in Haskell. Started initially as a programming homework. Now development still in progress. The language takes the idea from Unlambda:
- Everything is a function. Functions are things that map functions to functions (and hence have no type at all).
However, important language sugars and modifications are added:
- Lambda is introduced back, for the sake of any sane soul. A Lisp-style syntax is used. So I = ((S K) K).
- Pure functional design, with referential transparency, lazy evaluation and CPS IO operation. There is no strictness nor delayed application.
- Module system, standard library and syntax sugar for CPS.
U.hs uses file extension .u. Example of helloworld.u:
(import* io)
(def main (run
(_ (putStrLn "hello world"))
(exit 0)
)
)
The "run" statement is syntax sugar for chaining callbacks: (run (a b) (c d) e) = (b (\a (d (\c e)))). All io functions use callback to get the return value. Exit takes no callback (and hence stops execution).
To interpretively run the program call urun
$ghc urun.hs
$./urun helloworld.u
hello world
A basic repl calculator is also included.
$runghc urepl.hs
; type :q to quit, :? for help
prelude>(+ 3 1)
4
prelude>(import* io)
prelude io>(putStrLn "ha" print)
ha
0
>:q
Note that, "print" is just the identity function (\x x). When using it as a callback, the execution is terminated with result printed.
TODO