Testsuite: tabs -> spaces [skip ci]
[ghc.git] / testsuite / tests / simplCore / should_compile / simpl003.hs
1 -- !! INLINE on recursive functions.
2 {-
3 Date: Thu, 8 Dec 94 11:38:24 GMT
4 From: Julian Seward (DRL PhD) <sewardj@computer-science.manchester.ac.uk>
5 Message-Id: <9412081138.AA16652@rdf009.cs.man.ac.uk>
6 To: partain@dcs.gla.ac.uk
7 -}
8 module ShouldCompile where
9
10 type IMonad a
11 = IMonadState -> IMonadReturn a
12
13 data IMonadReturn a
14 = IMonadOk IMonadState a
15 | IMonadFail IMonadState String
16
17 type IMonadState
18 = Int
19
20
21 returnI r = \s0 -> IMonadOk s0 r
22
23 failI msg = \s0 -> IMonadFail s0 msg
24
25 thenI m k
26 = \s0 -> case m s0 of
27 IMonadFail s1 msg -> IMonadFail s1 msg
28 IMonadOk s1 r1 -> k r1 s1
29
30 tickI n = \s0 -> IMonadOk (s0+n) ()
31
32 mapI f [] = returnI []
33 mapI f (x:xs) = f x `thenI` ( \ fx ->
34 mapI f xs `thenI` ( \ fxs ->
35 returnI (fx:fxs)
36 ))
37
38 {-# INLINE returnI #-}
39 {-# INLINE failI #-}
40 {-# INLINE thenI #-}
41 {-# INLINE tickI #-}
42 -- {-# INLINE mapI #-}