Skip to content

Commit 42776bf

Browse files
committed
Rank 2 Types Example
1 parent 79ba455 commit 42776bf

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Main.hs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ examples =
116116
("FFI",
117117
unlines [ "foreign import data IO :: * -> *"
118118
, ""
119-
, "foreign import console :: {"
120-
, " log :: String -> IO { }"
121-
, "}"
119+
, "foreign import console :: { log :: String -> IO { } }"
122120
, ""
123121
, "main = console.log \"Hello World!\""
124122
]))
@@ -145,6 +143,21 @@ examples =
145143
, ""
146144
, "test = Test:incr 10"
147145
]))
146+
, ("rank2",
147+
("Rank N Types",
148+
unlines [ "type Nat = forall a. a -> (a -> a) -> a"
149+
, ""
150+
, "zero :: Nat"
151+
, "zero = \\a f -> a"
152+
, ""
153+
, "succ :: Nat -> Nat"
154+
, "succ = \\n a f -> f (n a f)"
155+
, ""
156+
, "type Lens a b = forall f. (a -> f a) -> b -> f b"
157+
, ""
158+
, "compose :: forall a b c. Lens a b -> Lens b c -> Lens a c"
159+
, "compose = \\l1 l2 f -> l2 (l1 f)"
160+
]))
148161
]
149162

150163
page :: Maybe String -> Maybe Response -> ActionM ()

0 commit comments

Comments
 (0)