summaryrefslogtreecommitdiff
path: root/Main.hs
blob: e5aa5129b3974e8a543af3c2d02792d2f36d6a72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Main where

import Eval (eval)
import Language
import Show (showExpr)
import Simplify (simplify)


main :: IO ()
main = do
    print . eval $
        let_ (add (con (2 :: Int)) (con 3)) $ \_ x ->
            mul x x

    let prog =
            let_ (add (con (2 :: Int)) (con 3)) $ \_ x ->
            let_ (mul (con (4 :: Int)) (con 5)) $ \wy y ->
            let_ (pair (wy x) y) $ \wt t ->
                add (mul (wt (wy x)) (snd_ t)) (mul (wt y) (fst_ t))
    putStrLn (showExpr prog)
    putStrLn (showExpr (simplify prog))
    print (eval prog)