Add examples of higher ranked polymorphism
This commit is contained in:
parent
789774d802
commit
c1768b0161
5 changed files with 36 additions and 0 deletions
BIN
demo/rank2
Executable file
BIN
demo/rank2
Executable file
Binary file not shown.
8
demo/rank2.crf
Normal file
8
demo/rank2.crf
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
applyId : (forall a. a -> a) -> b -> b
|
||||
applyId f x = f x
|
||||
|
||||
id : a -> a
|
||||
id x = x
|
||||
|
||||
main = applyId id 145
|
||||
BIN
demo/rank4
Executable file
BIN
demo/rank4
Executable file
Binary file not shown.
20
demo/rank4.crf
Normal file
20
demo/rank4.crf
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
.+ : Int -> Int -> Int
|
||||
.+ x y = 0
|
||||
|
||||
const : a -> b -> a
|
||||
const x y = x
|
||||
|
||||
applyapplyapplyId : (forall c. c -> (forall b. (forall a. a -> a) -> b -> b) -> c) -> d -> d
|
||||
applyapplyapplyId f x = f x applyId
|
||||
|
||||
applyapplyId : c -> (forall b. (forall a. a -> a) -> b -> b) -> c
|
||||
applyapplyId x f = f id x
|
||||
|
||||
applyId : (forall a. a -> a) -> b -> b
|
||||
applyId f x = f x
|
||||
|
||||
id : a -> a
|
||||
id x = x
|
||||
|
||||
main = applyapplyapplyId applyapplyId 50 + const 100 (applyapplyapplyId applyapplyId 'G')
|
||||
8
sample-programs/working/rank2.crf
Normal file
8
sample-programs/working/rank2.crf
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
applyId : (forall a. a -> a) -> b -> b
|
||||
applyId f x = f x
|
||||
|
||||
id : a -> a
|
||||
id x = x
|
||||
|
||||
main = applyId id 145
|
||||
Loading…
Add table
Add a link
Reference in a new issue