8e58652db65e08ecedc44d6c110790e3b5eb4dc5
[ghc.git] / testsuite / tests / eyeball / inline1.hs
1 {-# OPTIONS_GHC -fglasgow-exts -O -ddump-simpl -fno-method-sharing #-}
2 module Roman where
3
4 import Control.Monad.ST
5
6 newtype T s a = T { unT :: Int -> ST s a }
7
8 instance Monad (T s) where
9 return = T . const . return
10 T p >>= f = T $ \i -> do { x <- p i
11 ; unT (f x) i }
12
13 myIndex :: T s Int
14 {-# INLINE myIndex #-}
15 myIndex = T return
16
17 foo :: T s Int
18 foo = do { x <- myIndex
19 ; return (x + 1) }
20
21
22 {- At one stage we got code looking like this:
23
24 U.a3 =
25 \ (@ s_a8E) (i_shA :: GHC.Base.Int) (eta_shB :: GHC.Prim.State# s_a8E) ->
26 case ((((U.myIndex @ s_a8E)
27 `cast` ...)
28 i_shA)
29 `cast` ...)
30 eta_shB
31 of wild_si5 { (# new_s_shF, r_shG #) -> ...
32
33 U.foo :: forall s_a5S. U.T s_a5S GHC.Base.Int
34 U.foo = U.a3 `cast` ...
35
36
37 The point is that myIndex should be inlined, else code is bad -}