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