Embrace -XTypeInType, add -XStarIsType
[ghc.git] / testsuite / tests / simplCore / should_run / T14178.hs
1 import System.Exit
2 import Control.Monad.Trans.State.Strict
3
4 eval :: Int -> State Int a -> a
5 eval p = fst . flip runState p
6
7 advance :: Int -> State Int ()
8 advance = modify' . (+)
9
10 loc :: State Int Int
11 loc = get
12
13 emit1 :: State Int ()
14 emit1 = advance 1
15
16 emitN :: Int -> State Int ()
17 -- adding in the 0 case, breaks with HEAD. 8.2.1 is fine with it.
18 -- emitN 0 = advance 0
19 emitN 0 = pure ()
20 emitN n = advance n
21
22 align8 :: State Int ()
23 align8 = do
24 bits <- (`mod` 8) <$> loc
25 emitN (8 - bits)
26
27 main :: IO ()
28 main = do
29 let p = eval 0 (emit1 >> align8 >> loc)
30 putStrLn $ show p
31 if p == 8
32 then putStrLn "OK" >> exitSuccess
33 else putStrLn "FAIL" >> exitFailure