summaryrefslogtreecommitdiff
path: root/testdata/language-features/recursion
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-05-11 20:57:07 +0200
committerPéter Diviánszky <divipp@gmail.com>2016-05-12 00:50:34 +0200
commite4725c07ee3e7e3fc010df418d16f37c39b0af0f (patch)
treecb10e1d1203eed875955097311ccbe0943564226 /testdata/language-features/recursion
parent95e006bf5afa8d3473e3fe4401f4c9316186a428 (diff)
mutual function definitions
Diffstat (limited to 'testdata/language-features/recursion')
-rw-r--r--testdata/language-features/recursion/mutualConst.lc9
-rw-r--r--testdata/language-features/recursion/mutualConst.out195
-rw-r--r--testdata/language-features/recursion/mutualFunc.lc11
-rw-r--r--testdata/language-features/recursion/mutualFunc.out107
-rw-r--r--testdata/language-features/recursion/mutualRec.lc10
-rw-r--r--testdata/language-features/recursion/mutualRec.out140
-rw-r--r--testdata/language-features/recursion/simplerec01.out17
7 files changed, 473 insertions, 16 deletions
diff --git a/testdata/language-features/recursion/mutualConst.lc b/testdata/language-features/recursion/mutualConst.lc
index c7f83f18..526a14a7 100644
--- a/testdata/language-features/recursion/mutualConst.lc
+++ b/testdata/language-features/recursion/mutualConst.lc
@@ -1,9 +1,14 @@
1{-# LANGUAGE NoImplicitPrelude #-}
2import Internals
1 3
2xy = (\x y -> ((1 :: Int): y, 1: x)) (fst xy) (snd xy) 4fst (x, y) = x
5snd (x, y) = y
6
7xy = (\x y -> (False: y, True: x)) (fst xy) (snd xy)
3 8
4(x, y) = xy 9(x, y) = xy
5 10
6main = case x of 11main = case x of
7 1: 1: 1: _ -> True 12 False: True: False: _ -> True
8 13
9 14
diff --git a/testdata/language-features/recursion/mutualConst.out b/testdata/language-features/recursion/mutualConst.out
index 4791ed55..34d37bc7 100644
--- a/testdata/language-features/recursion/mutualConst.out
+++ b/testdata/language-features/recursion/mutualConst.out
@@ -1 +1,194 @@
1True \ No newline at end of file 1main :: Bool
2main = True
3------------ desugared source code
4fst
5 = _lhs
6 fst
7 \(a :: _) -> hlistConsCase
8 _
9 (\(b :: _) (c :: _) -> hlistConsCase
10 _
11 (\(_ :: _) (d :: _) -> hlistNilCase _ (_rhs b) d)
12 c)
13 a
14
15snd
16 = _lhs
17 snd
18 \(a :: _) -> hlistConsCase
19 _
20 (\(_ :: _) (b :: _) -> hlistConsCase
21 _
22 (\(c :: _) (d :: _) -> hlistNilCase _ (_rhs c) d)
23 b)
24 a
25
26xy
27 = primFix
28 \(a :: _) -> _lhs
29 xy
30 (_rhs ((\(b :: _) (c :: _) -> (False : c, True : b)) (fst a) (snd a)))
31
32_y_x = _lhs _y_x (_rhs xy)
33
34y
35 = _lhs
36 y
37 (_rhs
38 ((\(a :: _) -> hlistConsCase
39 _
40 (\(_ :: _) (b :: _) -> hlistConsCase
41 _
42 (\(c :: _) (d :: _) -> hlistNilCase _ c d)
43 b)
44 a)
45 _y_x))
46
47x
48 = _lhs
49 x
50 (_rhs
51 ((\(a :: _) -> hlistConsCase
52 _
53 (\(b :: _) (c :: _) -> hlistConsCase
54 _
55 (\(_ :: _) (d :: _) -> hlistNilCase _ b d)
56 c)
57 a)
58 _y_x))
59
60main
61 = _lhs
62 main
63 (_rhs
64 ((\(a :: _) -> case'List
65 (\(_ :: _) -> _)
66 undefined
67 (\(b :: _) (c :: _) -> case'Bool
68 (\(_ :: _) -> _)
69 (case'List
70 (\(_ :: _) -> _)
71 undefined
72 (\(d :: _) (e :: _) -> case'Bool
73 (\(_ :: _) -> _)
74 undefined
75 (case'List
76 (\(_ :: _) -> _)
77 undefined
78 (\(f :: _) (_ :: _) -> case'Bool (\(_ :: _) -> _) True undefined f)
79 e)
80 d)
81 c)
82 undefined
83 b)
84 a)
85 x))
86------------ core code
87_y_x :: ([Bool], [Bool])
88_y_x = _rhs (False : snd xy, True : fst xy)
89
90fst :: forall a b . (a, b) -> a
91fst
92 = \a b c -> hlistConsCase
93 a
94 [b]
95 a
96 (\d e -> hlistConsCase b [] a (\_ f -> hlistNilCase a (_rhs d) f) e)
97 c
98
99main :: Bool
100main = _rhs True
101
102snd :: forall a b . (a, b) -> b
103snd
104 = \a b c -> hlistConsCase
105 a
106 [b]
107 b
108 (\_ d -> hlistConsCase b [] b (\e f -> hlistNilCase b (_rhs e) f) d)
109 c
110
111x :: [Bool]
112x = _rhs (False : snd xy)
113
114xy :: ([Bool], [Bool])
115xy = primFix _ \a -> _rhs (False : snd a, True : fst a)
116
117y :: [Bool]
118y = _rhs (True : fst xy)
119------------ tooltips
120testdata/language-features/recursion/mutualConst.lc 4:1-4:4
121 forall a b . (a, b) -> a
122testdata/language-features/recursion/mutualConst.lc 4:14-4:15
123 _k | _h | _d
124testdata/language-features/recursion/mutualConst.lc 5:1-5:4
125 forall a b . (a, b) -> b
126testdata/language-features/recursion/mutualConst.lc 5:14-5:15
127 _f | _c | _c
128testdata/language-features/recursion/mutualConst.lc 7:1-7:3
129 ([Bool], [Bool])
130testdata/language-features/recursion/mutualConst.lc 7:6-7:44
131 [Bool] -> ([Bool], [Bool])
132testdata/language-features/recursion/mutualConst.lc 7:6-7:53
133 ([Bool], [Bool])
134testdata/language-features/recursion/mutualConst.lc 7:15-7:34
135 ([Bool], [Bool])
136testdata/language-features/recursion/mutualConst.lc 7:16-7:21
137 Bool
138testdata/language-features/recursion/mutualConst.lc 7:16-7:22
139 [Bool] -> [Bool]
140testdata/language-features/recursion/mutualConst.lc 7:16-7:24
141 [Bool]
142testdata/language-features/recursion/mutualConst.lc 7:21-7:22
143 forall a . a -> [a] -> [a]
144testdata/language-features/recursion/mutualConst.lc 7:23-7:24
145 _c
146testdata/language-features/recursion/mutualConst.lc 7:26-7:30
147 Bool
148testdata/language-features/recursion/mutualConst.lc 7:26-7:31
149 [Bool] -> [Bool]
150testdata/language-features/recursion/mutualConst.lc 7:26-7:33
151 [Bool] | (([Bool]))
152testdata/language-features/recursion/mutualConst.lc 7:30-7:31
153 forall a . a -> [a] -> [a]
154testdata/language-features/recursion/mutualConst.lc 7:32-7:33
155 _e
156testdata/language-features/recursion/mutualConst.lc 7:37-7:40
157 forall a b . (a, b) -> a
158testdata/language-features/recursion/mutualConst.lc 7:37-7:43
159 _b
160testdata/language-features/recursion/mutualConst.lc 7:41-7:43
161 _d
162testdata/language-features/recursion/mutualConst.lc 7:46-7:49
163 forall a b . (a, b) -> b
164testdata/language-features/recursion/mutualConst.lc 7:46-7:52
165 [Bool]
166testdata/language-features/recursion/mutualConst.lc 7:50-7:52
167 ([Bool], [Bool])
168testdata/language-features/recursion/mutualConst.lc 9:2-9:3
169 _k | _h | _d | [Bool]
170testdata/language-features/recursion/mutualConst.lc 9:2-9:6
171 ([Bool], [Bool]) | ([Bool], [Bool]) | ([Bool], [Bool])
172testdata/language-features/recursion/mutualConst.lc 9:5-9:6
173 _f | _c | _c | [Bool]
174testdata/language-features/recursion/mutualConst.lc 9:10-9:12
175 ([Bool], [Bool])
176testdata/language-features/recursion/mutualConst.lc 11:1-11:5
177 Bool
178testdata/language-features/recursion/mutualConst.lc 11:8-12:34
179 Bool
180testdata/language-features/recursion/mutualConst.lc 11:13-11:14
181 [Bool]
182testdata/language-features/recursion/mutualConst.lc 12:30-12:34
183 Bool | Bool | Bool | Bool | Bool | Bool
184------------ warnings
185Uncovered pattern(s) at testdata/language-features/recursion/mutualConst.lc:11:13:
186main = case x of
187 ^
188Missing case(s):
189 []
190 [False]
191 (False : False : _)
192 [False, True]
193 (False : True : True : _)
194 (True : _) \ No newline at end of file
diff --git a/testdata/language-features/recursion/mutualFunc.lc b/testdata/language-features/recursion/mutualFunc.lc
new file mode 100644
index 00000000..2f3a524e
--- /dev/null
+++ b/testdata/language-features/recursion/mutualFunc.lc
@@ -0,0 +1,11 @@
1{-# LANGUAGE NoImplicitPrelude #-}
2import Internals
3
4f True = g False
5f False = g True
6
7g True = True
8g x = f x
9
10main = f True
11
diff --git a/testdata/language-features/recursion/mutualFunc.out b/testdata/language-features/recursion/mutualFunc.out
new file mode 100644
index 00000000..6dd3f158
--- /dev/null
+++ b/testdata/language-features/recursion/mutualFunc.out
@@ -0,0 +1,107 @@
1main :: Bool
2main = True
3------------ desugared source code
4_g_f
5 = primFix
6 \(a :: _) -> let
7 b = a;
8 c
9 = (\(e :: _) -> hlistConsCase
10 _
11 (\(_ :: _) (f :: _) -> hlistConsCase
12 _
13 (\(g :: _) (h :: _) -> hlistNilCase _ g h)
14 f)
15 e)
16 b;
17 d
18 = (\(i :: _) -> hlistConsCase
19 _
20 (\(j :: _) (k :: _) -> hlistConsCase
21 _
22 (\(_ :: _) (l :: _) -> hlistNilCase _ j l)
23 k)
24 i)
25 b
26 in (_lhs g \(m :: _) -> case'Bool (\(_ :: _) -> _) (_rhs (c m)) (_rhs True) m
27 , _lhs
28 f
29 \(n :: _) -> case'Bool (\(_ :: _) -> _) (_rhs (d True)) (_rhs (d False)) n)
30
31_f_g = _g_f
32
33f
34 = (\(a :: _) -> hlistConsCase
35 _
36 (\(_ :: _) (b :: _) -> hlistConsCase
37 _
38 (\(c :: _) (d :: _) -> hlistNilCase _ c d)
39 b)
40 a)
41 _f_g
42
43g
44 = (\(a :: _) -> hlistConsCase
45 _
46 (\(b :: _) (c :: _) -> hlistConsCase
47 _
48 (\(_ :: _) (d :: _) -> hlistNilCase _ b d)
49 c)
50 a)
51 _f_g
52
53main = _lhs main (_rhs (f True))
54------------ core code
55_f_g :: (Bool -> Bool, Bool -> Bool)
56_f_g = primFix _ \a -> <<1st constructor of 'HList>>
57
58_g_f :: (Bool -> Bool, Bool -> Bool)
59_g_f = primFix _ \a -> <<1st constructor of 'HList>>
60
61f :: Bool -> Bool
62f = \a -> case'Bool (\_ -> 'Bool) (_rhs True) (_rhs True) a
63
64g :: Bool -> Bool
65g = \a -> case'Bool (\_ -> 'Bool) (_rhs (f a)) (_rhs True) a
66
67main :: Bool
68main = _rhs True
69------------ tooltips
70testdata/language-features/recursion/mutualFunc.lc 4:1-4:2
71 _f | _c | _c | _f | _c | _c | Bool -> Bool
72testdata/language-features/recursion/mutualFunc.lc 4:1-7:2
73 _b | _e | (_e, _d) | (Bool -> Bool, Bool -> Bool) | (Bool -> Bool
74 , Bool -> Bool) | (Bool -> Bool, Bool -> Bool) | (Bool -> Bool
75 , Bool -> Bool) | (Bool -> Bool, Bool -> Bool)
76testdata/language-features/recursion/mutualFunc.lc 4:10-4:11
77 Bool -> _a
78testdata/language-features/recursion/mutualFunc.lc 4:10-4:17
79 _a
80testdata/language-features/recursion/mutualFunc.lc 4:10-5:17
81 Bool -> _a | ((Bool -> _a))
82testdata/language-features/recursion/mutualFunc.lc 4:10-8:10
83 (Bool -> Bool, Bool -> _a)
84testdata/language-features/recursion/mutualFunc.lc 4:12-4:17
85 Bool
86testdata/language-features/recursion/mutualFunc.lc 5:11-5:12
87 _i
88testdata/language-features/recursion/mutualFunc.lc 5:13-5:17
89 Bool
90testdata/language-features/recursion/mutualFunc.lc 7:1-7:2
91 _k | _h | _d | _k | _h | _d | Bool -> Bool
92testdata/language-features/recursion/mutualFunc.lc 7:10-7:14
93 Bool
94testdata/language-features/recursion/mutualFunc.lc 7:10-8:10
95 Bool -> Bool
96testdata/language-features/recursion/mutualFunc.lc 8:7-8:8
97 _h
98testdata/language-features/recursion/mutualFunc.lc 8:9-8:10
99 _f
100testdata/language-features/recursion/mutualFunc.lc 10:1-10:5
101 Bool
102testdata/language-features/recursion/mutualFunc.lc 10:8-10:9
103 Bool -> Bool
104testdata/language-features/recursion/mutualFunc.lc 10:8-10:14
105 Bool
106testdata/language-features/recursion/mutualFunc.lc 10:10-10:14
107 Bool \ No newline at end of file
diff --git a/testdata/language-features/recursion/mutualRec.lc b/testdata/language-features/recursion/mutualRec.lc
index c9ae6135..9a9422de 100644
--- a/testdata/language-features/recursion/mutualRec.lc
+++ b/testdata/language-features/recursion/mutualRec.lc
@@ -1,8 +1,10 @@
1{-# LANGUAGE NoImplicitPrelude #-}
2import Internals
1 3
2x = 2: y 4x = False: y
3y = 1: x 5y = True: x
4 6
5main = case (x :: [Int]) of 7main = case x of
6 2: 1: 2: _ -> True 8 False: True: False: _ -> True
7 9
8 10
diff --git a/testdata/language-features/recursion/mutualRec.out b/testdata/language-features/recursion/mutualRec.out
index 4791ed55..885bd1ba 100644
--- a/testdata/language-features/recursion/mutualRec.out
+++ b/testdata/language-features/recursion/mutualRec.out
@@ -1 +1,139 @@
1True \ No newline at end of file 1main :: Bool
2main = True
3------------ desugared source code
4_y_x
5 = primFix
6 \(a :: _) -> let
7 b = a;
8 c
9 = (\(e :: _) -> hlistConsCase
10 _
11 (\(_ :: _) (f :: _) -> hlistConsCase
12 _
13 (\(g :: _) (h :: _) -> hlistNilCase _ g h)
14 f)
15 e)
16 b;
17 d
18 = (\(i :: _) -> hlistConsCase
19 _
20 (\(j :: _) (k :: _) -> hlistConsCase
21 _
22 (\(_ :: _) (l :: _) -> hlistNilCase _ j l)
23 k)
24 i)
25 b
26 in (_lhs y (_rhs (True : c)), _lhs x (_rhs (False : d)))
27
28_x_y = _y_x
29
30x
31 = (\(a :: _) -> hlistConsCase
32 _
33 (\(_ :: _) (b :: _) -> hlistConsCase
34 _
35 (\(c :: _) (d :: _) -> hlistNilCase _ c d)
36 b)
37 a)
38 _x_y
39
40y
41 = (\(a :: _) -> hlistConsCase
42 _
43 (\(b :: _) (c :: _) -> hlistConsCase
44 _
45 (\(_ :: _) (d :: _) -> hlistNilCase _ b d)
46 c)
47 a)
48 _x_y
49
50main
51 = _lhs
52 main
53 (_rhs
54 ((\(a :: _) -> case'List
55 (\(_ :: _) -> _)
56 undefined
57 (\(b :: _) (c :: _) -> case'Bool
58 (\(_ :: _) -> _)
59 (case'List
60 (\(_ :: _) -> _)
61 undefined
62 (\(d :: _) (e :: _) -> case'Bool
63 (\(_ :: _) -> _)
64 undefined
65 (case'List
66 (\(_ :: _) -> _)
67 undefined
68 (\(f :: _) (_ :: _) -> case'Bool (\(_ :: _) -> _) True undefined f)
69 e)
70 d)
71 c)
72 undefined
73 b)
74 a)
75 x))
76------------ core code
77_x_y :: ([Bool], [Bool])
78_x_y = primFix _ \a -> <<1st constructor of 'HList>>
79
80_y_x :: ([Bool], [Bool])
81_y_x = primFix _ \a -> <<1st constructor of 'HList>>
82
83main :: Bool
84main = _rhs True
85
86x :: [Bool]
87x = _rhs (False : y)
88
89y :: [Bool]
90y = _rhs (True : x)
91------------ tooltips
92testdata/language-features/recursion/mutualRec.lc 4:1-4:2
93 _f | _c | _c | _f | _c | _c | [Bool]
94testdata/language-features/recursion/mutualRec.lc 4:1-5:2
95 _b | _e | (_e, _d) | ([Bool], [Bool]) | ([Bool], [Bool]) | ([Bool]
96 , [Bool]) | ([Bool], [Bool]) | ([Bool], [Bool])
97testdata/language-features/recursion/mutualRec.lc 4:5-4:10
98 Bool
99testdata/language-features/recursion/mutualRec.lc 4:5-4:11
100 [Bool] -> [Bool]
101testdata/language-features/recursion/mutualRec.lc 4:5-4:13
102 [Bool] | (([Bool]))
103testdata/language-features/recursion/mutualRec.lc 4:5-5:12
104 ([Bool], [Bool])
105testdata/language-features/recursion/mutualRec.lc 4:10-4:11
106 forall a . a -> [a] -> [a]
107testdata/language-features/recursion/mutualRec.lc 4:12-4:13
108 _e
109testdata/language-features/recursion/mutualRec.lc 5:1-5:2
110 _k | _h | _d | _k | _h | _d | [Bool]
111testdata/language-features/recursion/mutualRec.lc 5:5-5:9
112 Bool
113testdata/language-features/recursion/mutualRec.lc 5:5-5:10
114 [Bool] -> [Bool]
115testdata/language-features/recursion/mutualRec.lc 5:5-5:12
116 [Bool]
117testdata/language-features/recursion/mutualRec.lc 5:9-5:10
118 forall a . a -> [a] -> [a]
119testdata/language-features/recursion/mutualRec.lc 5:11-5:12
120 _d
121testdata/language-features/recursion/mutualRec.lc 7:1-7:5
122 Bool
123testdata/language-features/recursion/mutualRec.lc 7:8-8:34
124 Bool
125testdata/language-features/recursion/mutualRec.lc 7:13-7:14
126 [Bool]
127testdata/language-features/recursion/mutualRec.lc 8:30-8:34
128 Bool | Bool | Bool | Bool | Bool | Bool
129------------ warnings
130Uncovered pattern(s) at testdata/language-features/recursion/mutualRec.lc:7:13:
131main = case x of
132 ^
133Missing case(s):
134 []
135 [False]
136 (False : False : _)
137 [False, True]
138 (False : True : True : _)
139 (True : _) \ No newline at end of file
diff --git a/testdata/language-features/recursion/simplerec01.out b/testdata/language-features/recursion/simplerec01.out
index 736caa77..823d544e 100644
--- a/testdata/language-features/recursion/simplerec01.out
+++ b/testdata/language-features/recursion/simplerec01.out
@@ -1,18 +1,19 @@
1main is not found 1main is not found
2------------ desugared source code 2------------ desugared source code
3fun 3fun
4 = _lhs 4 = primFix
5 fun 5 \(a :: _) -> _lhs
6 \(a :: _) -> case'Bool 6 fun
7 (\(_ :: _) -> _) 7 \(b :: _) -> case'Bool
8 (_rhs (fun (fromInt 0))) 8 (\(_ :: _) -> _)
9 (_rhs 'a') 9 (_rhs (a (fromInt 0)))
10 (fromInt 0 == a) 10 (_rhs 'a')
11 (fromInt 0 == b)
11------------ core code 12------------ core code
12fun :: forall a . (Num a, Eq a, Num a) => a -> Char 13fun :: forall a . (Num a, Eq a, Num a) => a -> Char
13fun 14fun
14 = \a b c d -> primFix 15 = \a b c d -> primFix
15 (a -> 'Char) 16 _
16 \e f -> case'Bool 17 \e f -> case'Bool
17 (\_ -> 'Char) 18 (\_ -> 'Char)
18 (_rhs (e (fromInt a b 0))) 19 (_rhs (e (fromInt a b 0)))