on 625f239 help sign in
111 lines 1.4 kB history raw
1{-# LANGUAGE RecursiveDo #-}
3bar = do foo; bar
5baz =
6 mdo
7 bar a
8 a <- foo
9 b <-
10 bar
11 1
12 2
13 3
14 return (a + b)
16baz = do
17 a <- foo
18 let b = a + 2
19 c = b + 3
20 bar c
21 let d = c + 2
22 return d
24quux = something $ do
25 foo
26 case x of
27 1 -> 10
28 2 -> 20
29 bar
30 if something
31 then x
32 else y
33 baz
35foo = do
36 rec a <- b + 5
37 let d = c
38 b <- a * 5
39 something
40 c <- a + b
41 print c
42 rec something $ do
43 x <- a
44 print x
45 y <- c
46 print y
48trickyLet = do
49 foo
50 let x = 5
51 in bar x
53f = unFoo . foo bar baz 3 $ do
54 act
55 ret
57g = unFoo
58 . foo
59 bar
60 baz
61 3
62 $ do
63 act
64 ret
66main =
67 do stuff
68 `finally` do
69 recover
71main = do stuff `finally` recover
73main = do { stuff } `finally` recover
75foo = do do { foo; bar }; baz
77foo =
78 do
79 1
80 + 2
82-- single line let-where
83samples n f = do
84 gen <- newQCGen
85 let rands g = g1 : rands g2 where { (g1, g2) = split g }
86 return $ rands gen
88main = do bar
90main = do bar; baz
92main = do
93 bar
94 baz
96main = do
97 a <- bar
98 let a = b; c = d
99 baz d
100 let e = f
101 g = h
102 return c
104readInClause = do
105 do
106 lookAhead g_Do
107 parseNote ErrorC 1063 "You need a line feed or semicolon before the 'do'."
108 <|> do
109 optional g_Semi
110 void allspacing
111 return things