5 :: Tree a b = Tip a | Bin b (Tree a b) (Tree a b)
6 :: Rose a = Rose a .[Rose a]
8 :: Sequ a = SequEmpty | SequZero .(Sequ .(Fork a)) | SequOne a .(Sequ .(Fork a))
10 = :+: infixl 2 InfCons InfCons
11 | :-: infixl 2 InfCons InfCons
12 | :*: infixl 3 InfCons InfCons
13 | :->: infixr 4 InfCons InfCons
16 :: Rec a b c = { rec_fst :: a, rec_snd :: b, rec_thd :: c }
17 :: Color = Red | Green | Blue
19 derive bimap Tree, Rose, Fork, Sequ
21 derive gEq Tree, Rose, Fork, Sequ, Color, InfCons, Rec, Maybe
22 derive gLexOrd Tree, Rose, Fork, Sequ
23 derive gMap Tree, Rose, Fork, Sequ
24 derive gMapLSt Tree, Rose, Fork, Sequ
25 derive gMapRSt Tree, Rose, Fork, Sequ
26 derive gMapLM Tree, Rose, Fork, Sequ
27 derive gMapRM Tree, Rose, Fork, Sequ
28 derive gReduceLSt Tree, Rose, Fork, Sequ
29 derive gReduceRSt Tree, Rose, Fork, Sequ
30 derive gReduce Tree, Rose, Fork, Sequ
31 derive gZip Tree, Rose, Fork, Sequ
32 derive gMaybeZip Tree, Rose, Fork, Sequ
33 derive gPrint Tree, Rose, Fork, Sequ, Color, InfCons, Rec
34 derive gParse Tree, Rose, Fork, Sequ, Color, InfCons, Rec
35 derive gCompress Tree, Rose, Fork, Sequ, Color
36 derive gCompressedSize Tree, Rose, Fork, Sequ, Color
37 derive gUncompress Tree, Rose, Fork, Sequ, Color
38 derive gLookupFMap Tree, Rose, Fork, Sequ, Color
39 derive gInsertFMap Tree, Rose, Fork, Sequ, Color
41 tree = Bin 1 (Bin 2 (Tip 1.1) (Tip 2.2)) (Bin 3 (Tip 3.3) (Tip 4.4))
42 rose = Rose 1 [Rose 2 [], Rose 3 [Rose 5 [], Rose 6 []], Rose 4[]]
43 sequ = SequZero (SequOne (Fork 1 2) (SequOne (Fork (Fork 3 4) (Fork 5 6)) SequEmpty))
48 , [1,2,3] =!= [1,2,3,4]
56 [ ([1,2,3] =?= [1,2,3]) === EQ
57 , ([1,2,3] =?= [1,2,3,4]) === LT
58 , ([1,2,4] =?= [1,2,3,4]) === GT
59 , (Rose 1 [Rose 2 [], Rose 3 []] =?= Rose 1 [Rose 2 [], Rose 3 []]) === EQ
60 , (Rose 1 [Rose 2 [], Rose 3 []] =?= Rose 1 [Rose 2 [], Rose 3 [], Rose 4 []]) === LT
61 , (Rose 1 [Rose 2 [], Rose 4 []] =?= Rose 1 [Rose 2 [], Rose 3 [], Rose 4 []]) === GT
65 [ gMap{|*->*|} inc [1,2,3] === [2,3,4]
66 , gMap{|*->*->*|} inc dec (Bin 1 (Tip 2.0) (Tip 3.0)) === Bin 0 (Tip 3.0) (Tip 4.0)
67 , gMap{|*->*|} inc (Rose 1 [Rose 2 [], Rose 3 []]) === Rose 2 [Rose 3 [], Rose 4 []]
68 , gMap{|*->*|} inc (SequZero (SequOne (Fork 1 2) (SequOne (Fork (Fork 3 4) (Fork 5 6)) SequEmpty)))
69 === SequZero (SequOne (Fork 2 3) (SequOne (Fork (Fork 4 5) (Fork 6 7)) SequEmpty))
73 [ gMapRSt{|*->*|} (\x st-> (dec x, [x:st])) [1,2,3] [] === ([0,1,2], [1,2,3])
77 [ gMapLSt{|*->*|} (\x st-> (dec x, [x:st])) [1,2,3] [] === ([0,1,2], [3,2,1])
81 [ gReduceRSt{|*->*|} (\x st -> [x:st]) [1,2,3] [] === [1,2,3]
85 [ gReduceLSt{|*->*|} (\x st -> [x:st]) [1,2,3] [] === [3,2,1]
89 [ gMapRM{|*->*|} (Just o inc) [1,2,3] === (Just [2,3,4])
90 , (gMapRM{|*->*|} (\x -> {st_monad=(\xs -> (inc x, [x:xs]))}) [1,2,3]).st_monad [] === ([2,3,4], [1,2,3])
94 [ gMapLM{|*->*|} (Just o inc) [1,2,3] === (Just [2,3,4])
95 , (gMapLM{|*->*|} (\x -> {st_monad=(\xs -> (inc x, [x:xs]))}) [1,2,3]).st_monad [] === ([2,3,4], [3,2,1])
119 , test "Hello \"string\""
133 , test {rec_fst=1, rec_snd='a', rec_thd=1.2}
135 , test (Bin 'a' (Tip 1) (Bin 'b' (Tip 2) (Bin 'c' (Tip 3) (Tip 4))))
136 , test (Rose 1 [Rose 2 [], Rose 3 [], Rose 4 [Rose 5 []]])
139 , test (U :+: U :+: U)
140 , test (U :->: U :->: U)
141 , test (U :+: U :*: U)
142 , test (U :*: U :->: U)
143 , test (I 1 :+: I 2 :+: I 3)
144 , test (I 1 :*: I 2 :+: I 3)
145 , test (I 1 :+: I 2 :*: I 3)
146 , test (I 1 :+: I 2 :*: I 3 :+: I 4)
147 , test (I 1 :+: (I 2 :+: I 3) :+: I 4)
149 , test [I 1 :+: I 2 :+: I 3, I 4 :->: I 5 :->: I 6]
150 , test (arr [I 1 :+: I 2 :+: I 3, I 4 :->: I 5 :->: I 6])
152 { rec_fst = I 1 :+: I 2 :+: I 3
153 , rec_snd = I 4 :->: I 5 :->: I 6
154 , rec_thd = I 7 :*: I 8 :+: I 9
158 test x = case parseString (printToString x) of
176 , test (flatten (repeatn 100 [Red, Green, Blue]))
177 //, test (flatten (repeatn 100000 [Red, Green, Blue]))
184 , test (Bin Red (Tip Green) (Bin Blue (Tip Red) (Tip Green)))
188 test x = case uncompress (compress x) of
194 [ lookupFMap 1 fmap_int === Just 10
195 , lookupFMap 3 fmap_int === Just 30
196 , lookupFMap "two" fmap_str === Just 2
197 , lookupFMap "three" fmap_str === Just 3
198 , lookupFMap (Rose 1 [Rose 2 [], Rose 30 []]) fmap_rose === Just 3
199 , lookupFMap (Rose 1 [Rose 20 [], Rose 1 []]) fmap_rose === Just 100
214 fmap_rose = emptyFMap
215 <<= (Rose 1 [Rose 2 [], Rose 10 []], 1)
216 <<= (Rose 1 [Rose 2 [], Rose 20 []], 2)
217 <<= (Rose 1 [Rose 2 [], Rose 30 []], 3)
218 <<= (Rose 1 [Rose 2 [], Rose 40 []], 4)
219 <<= (Rose 1 [Rose 2 [], Rose 50 []], 5)
220 <<= (Rose 1 [Rose 20 [], Rose 1 []], 100)
224 # result = foldr (&&) True (flatten tests)