Add closures and fix lets in monomorphizer
This commit is contained in:
parent
677a200a15
commit
72e599d5de
26 changed files with 1440 additions and 692 deletions
16
sample-programs/working/map.crf
Normal file
16
sample-programs/working/map.crf
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
data List a where
|
||||
Nil : List a
|
||||
Cons : a -> List a -> List a
|
||||
|
||||
map : (a -> b) -> List a -> List b
|
||||
map f xs = case xs of
|
||||
Nil => Nil
|
||||
Cons x xs => Cons (f x) (map f xs)
|
||||
|
||||
sum : List Int -> Int
|
||||
sum xs = case xs of
|
||||
Nil => 0
|
||||
Cons x xs => x + (sum xs)
|
||||
|
||||
main = let y = 10 in sum (map (\x. x + y) (Cons 2 (Cons 4 Nil)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue