Add examples of higher ranked polymorphism

This commit is contained in:
Martin Fredin 2023-05-24 22:12:45 +02:00
parent 789774d802
commit c1768b0161
5 changed files with 36 additions and 0 deletions

20
demo/rank4.crf Normal file
View 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')