blob: 2968d9c3239efb5f7a60236aac0889ea194e0384 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
import Module_24_a_2
--import Control.Concurrent -- Non-strict versions
-- Test: The type constructors are accessible
-- mTypeConstructorAccessible :: IO (StrictMVar Int)
-- mTypeConstructorAccessible = newStrictEmptyMVar
-- cTypeConstructorAccessible :: IO (StrictChan Char)
-- cTypeConstructorAccessible = newStrictChan
-- Test: The data constructors are not accessible
-- mDataConstructorNotAccessible :: StrictMVar Int
-- mDataConstructorNotAccessible x = case x of
-- StrictM j -> undefined
-- cDataConstructorNotAccessible :: StrictChan Int
-- cDataConstructorNotAccessible x = case x of
-- StrictC j -> undefined
-- Test: It is not possible to change the import from the strict versions to
-- non-strict ones with this test still compiling
-- mStrict = do
-- x <- newStrictEmptyMVar
-- putMVar x 1
-- v <- takeMVar x
-- putStrLn $ show v
-- cStrict = do
-- x <- newStrictChan
-- writeChan x 2
-- v <- readChan x
-- putStrLn $ show v
-- Test: The non-strict versions do not evalute the value before placing it into
-- MVar or Chan
-- m1NonStrict = do
-- x <- newEmptyMVar
-- putMVar x undefined
-- return ()
-- m2NonStrict = do
-- x <- newMVar undefined
-- return ()
-- cNonStrict = do
-- x <- newChan
-- writeChan x undefined
-- return ()
-- Test: The strict versions evalute the value before placing it into MVar or
-- Chan
-- m1Strict = do
-- x <- newStrictEmptyMVar
-- putMVar x undefined
-- return ()
-- m2Strict = do
-- x <- newStrictMVar undefined
-- return ()
-- cStrict = do
-- x <- newStrictChan
-- writeChan x undefined
-- return ()
|