RecordTest3.curry 1.08 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import RecursiveRecords
import RecordTest2

r :: R Int
r = { f1 := 4, f2 := "hello" }

e = showR r

-- type R1 a b = { f1 :: a, f2 :: b }
-- type R2 = { f3 :: Int }
--
-- type R3 a b = { f5 :: a, f4 :: Maybe b }
--
-- type Person = { name :: String, age :: Int }
--
-- type Address = { person :: Person, street :: String, city :: String }
--
-- smith :: Person
-- smith = { name := "Smith", age := 20 }
--
-- a :: Address
-- a = { person := smith, street := "Main Street", city := "New York" }
23

24
-- p2 = { name := "Doe" }
25

26
-- data T = T (R3 Int)
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
--f :: R1 -> R1
--f x = x + 1

--g :: R3 Int -> R3 Int
--g x = not x

--r1 = { f1 := False, f2 := "" }

-- r2 :: R2
-- r2 = { f3 := Just 1 }

-- r3 :: R1 Bool String
--r3 = { f4 := Just 1, f5 := "" }

--inc :: Int -> Int
--inc = (+1)

-- e :: Maybe Bool
--sel1 = (r3 :> f5)

-- upd1 = { f1 := True | r2 }

-- upd2 = { f3 := True | r2 }

-- pat1 { name = "Smith", age = 25 } = True

-- pat2 { person = p | _} = p

--r1 :: R1
--r1 = { f1 := False, f2 := r2 }

--r3 :: R3 Int
--r3 = { f4 := "", f5 := Just 1 }

--e = { f2 := r3 | r1}

--type RR = { f6 :: RR }