File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ compile input = do
51
51
case P. compile modules of
52
52
Left error ->
53
53
return $ Response $ Left error
54
- Right (js, externs, _) ->
54
+ Right (js, externs, _) ->
55
55
return $ Response $ Right $ Compiled js externs
56
56
57
57
str :: String -> String
@@ -201,6 +201,27 @@ examples =
201
201
, " isEven 0 = true"
202
202
, " isEven n = isOdd (n - 1)"
203
203
]))
204
+ , (" do" ,
205
+ (" Do Notation" ,
206
+ unlines [ " module DoNotation where"
207
+ , " "
208
+ , " data Maybe a = Nothing | Just a"
209
+ , " "
210
+ , " bindMaybe Nothing _ = Nothing"
211
+ , " bindMaybe (Just a) f = f a"
212
+ , " "
213
+ , " maybe = { ret: Just, bind: bindMaybe }"
214
+ , " "
215
+ , " isEven n | n % 2 == 0 = Just {}"
216
+ , " isEven _ = Nothing"
217
+ , " "
218
+ , " evenSum a b = maybe do"
219
+ , " n <- a"
220
+ , " m <- b"
221
+ , " let sum = n + m"
222
+ , " isEven sum"
223
+ , " return sum"
224
+ ]))
204
225
]
205
226
206
227
page :: Maybe String -> Maybe Response -> ActionM ()
You can’t perform that action at this time.
0 commit comments