Ticket #785: kinds2.hs

File kinds2.hs, 498 bytes (added by guest, 8 years ago)

second example

Line 
1{-# OPTIONS_GHC -cpp -fglasgow-exts #-}
2import Data.Array.IO
3import Data.Array.Base
4import Locking
5
6type WithLocking2 a e m = WithLocking (a e m)
7
8instance (MArray a e m) => (MArray (WithLocking2 a) e m) where
9    newArray lu e = newArray lu e >>= addLocking
10    newArray_ lu  = newArray_ lu  >>= addLocking
11    unsafeRead = liftLock2 unsafeRead
12    unsafeWrite = liftLock3 unsafeWrite
13
14main = do arr <- newArray (0,9) 0 >>= addLocking
15          readArray arr 0 >>= writeArray arr 1