-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestFramework.hs
More file actions
45 lines (28 loc) · 1.1 KB
/
testFramework.hs
File metadata and controls
45 lines (28 loc) · 1.1 KB
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
module Main where
-- context C1 as Boolean {
-- <pull self; ; push self>
-- }
-- Java version:
-- abstract class AbstractC1 { Boolean get(); }
-- Haskell version:
data AbstractC1 = AbstractC1 {abstractC1_get :: () -> Bool}
-- context C2 as Boolean {
-- <pull self; pull C1 ; push self>
-- }
-- Boolean get(C1Closure c1);
data AbstractC2 = AbstractC2 {abstractC2_get :: (() -> Bool) -> Bool}
-- example implementation which negates the value returned by c1. Is
-- it possible to make that simpler? By merging the definitions?
myabstractC2_get :: (() -> Bool) -> Bool
myabstractC2_get c1Closure = not (c1Closure ())
myC2 = AbstractC2 myabstractC2_get
-- context C1Indexed as Boolean indexed by val as Integer {
-- <pull self; ; push self>
-- }
-- Boolean get(Integer val)
data AbstractC1Indexed = AbstractC1Indexed {abstractC1Indexed_get :: Integer -> Bool}
-- context C2Indexed as Boolean indexed by val as Integer {
-- <pull self; pull C1Indexed; push self>
-- }
-- Boolean get(C1Closure c1)
data AbstractC2Indexed = AbstractC2Indexed {abstractC2Indexed_get :: Integer -> (Integer -> Bool) -> Bool}