-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ShowParser.hs
More file actions
42 lines (33 loc) · 842 Bytes
/
test_ShowParser.hs
File metadata and controls
42 lines (33 loc) · 842 Bytes
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
module ParsecTutorial where
import ShowParser (parseShow)
data Address = MkAddress
{ line1 :: String,
number :: Integer,
street :: String,
town :: String,
postcode :: String
}
deriving (Show)
data Label = Green | Red | Blue | Yellow deriving (Show)
data PersonRecord = MkPersonRecord
{ name :: String,
address :: Address,
id :: Integer,
labels :: [Label]
}
deriving (Show)
rec1 =
MkPersonRecord
"Wim Vanderbauwhede"
(MkAddress "School of Computing Science" 17 "Lilybank Gdns" "Glasgow" "G12 8QQ")
557188
[Green, Red]
rec2 =
MkPersonRecord
"Jeremy Singer"
(MkAddress "School of Computing Science" 17 "Lilybank Gdns" "Glasgow" "G12 8QQ")
42
[Blue, Yellow]
-- main = putStrLn $ show [rec1, rec2]
rec_str = show [rec1, rec2]
main = putStrLn $ parseShow rec_str