Testsuite: delete Windows line endings [skip ci] (#11631)
[ghc.git] / testsuite / tests / gadt / rw.hs
1 {-# LANGUAGE GADTs #-}
2
3 module Main where
4
5 import Data.IORef
6
7 data T a where
8 Li:: Int -> T Int
9 Lb:: Bool -> T Bool
10 La:: a -> T a
11
12 writeInt:: T a -> IORef a -> IO ()
13 writeInt v ref = case v of
14 ~(Li x) -> writeIORef ref (1::Int)
15
16 readBool:: T a -> IORef a -> IO ()
17 readBool v ref = case v of
18 ~(Lb x) ->
19 readIORef ref >>= (print . not)
20
21 tt::T a -> IO ()
22 tt v = case v of
23 ~(Li x) -> print "OK"
24
25 main = do
26 tt (La undefined)
27 ref <- newIORef undefined
28 writeInt (La undefined) ref
29 readBool (La undefined) ref