File: Refs.hs

package info (click to toggle)
haskell-iospec 0.3.1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 144 kB
  • sloc: haskell: 971; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 597 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import Test.IOSpec
import Test.QuickCheck

readOnce :: Int -> IOSpec IORefS Int
readOnce x = do ref <- newIORef x
                readIORef ref

readTwice :: Int -> IOSpec IORefS Int
readTwice x = do ref <- newIORef x
                 readIORef ref
                 readIORef ref

readIORefProp :: Int -> Bool
readIORefProp x =
  let once  = evalIOSpec (readOnce x) singleThreaded
      twice = evalIOSpec (readTwice x) singleThreaded
  in once == twice

main = quickCheck readIORefProp

instance Eq a => Eq (Effect a) where
  (Done x) == (Done y) = x == y
  _ == _ = error "Incomparable effects."