git @ Cat's Eye Technologies Lanthorn / master
Merge branch 'master' of https://codeberg.org/catseye/Lanthorn Chris Pressey 1 year, 8 months ago
2 changed file(s) with 4 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
00 Lanthorn
11 ========
22
3 _Version 1.0_
3 Version 1.0 | _Entry_ @ [catseye.tc](https://catseye.tc/node/Lanthorn)
4 | _See also:_ [Lariat](https://catseye.tc/node/Lariat)
5 * [Iphigeneia](https://catseye.tc/node/Iphigeneia)
46
57 When I first came across a explanation of how `letrec` works, it was
68 in terms of updating references: each of the names is bound to a cell,
4042 ...and turn it into this.
4143
4244 let
43 odd0 = fun(x, odd$1, even$1) ->
45 odd0 = fun(x, odd1, even1) ->
4446 let
4547 odd = fun(x) -> odd1(x, odd1, even1)
4648 even = fun(x) -> even1(x, odd1, even1)
00 module Language.Lanthorn.LetRec where
11
22 import Language.Lanthorn.AST
3 import Language.Lanthorn.Pretty
43
54
65 convert (Fun formals body) = Fun formals (convert body)
1312 convertBindings :: [(String, Expr)] -> [(String, Expr)]
1413 convertBindings [] = []
1514 convertBindings ((name, expr):rest) = ((name, (convert expr)):(convertBindings rest))
16
17 convertArms [] = []
18 convertArms ((ante, cons):rest) = (((convert ante), (convert cons)):(convertArms rest))
1915
2016 convertToLetStar :: [(String, Expr)] -> Expr -> Expr
2117 convertToLetStar bindings body =