1 -- The translation of this program should assign only one dictionary to
2 -- the function search (an Ord dictionary). Instead, it assigns two.
3 -- The output produced currently displays this.
5 -- 10/12/92: This program is actually erroneous. The pattern-binding for
6 -- search falls under the monomorphism restriction, and there is no
7 -- call to search which might fix its type. So there should be a complaint.
8 -- But the actual error message is horrible:
10 -- "bug001.hs", line 26: Ambiguous overloading:
11 -- class "Ord_", type "a" (at a use of an overloaded identifier: gt)
12 -- class "Eq_", type "a" (at a use of an overloaded identifier: eq)
19 instance Eq_ Int where
22 instance (Eq_ a) => Eq_ [a] where
28 else and (eq (hd xs) (hd ys)) (eq (tl xs) (tl ys))
30 class (Eq_ a) => Ord_ a where
33 instance Ord_ Int where
37 = \ a bs -> if gt (hd bs) a
39 else if eq a (hd bs) then True else search a (tl bs)
41 and :: Bool -> Bool -> Bool
50 ordIntGt :: Int -> Int -> Bool
53 eqIntEq :: Int -> Int -> Bool
63 ===============================================
64 Main.Eq__INST_PreludeBuiltin.Int =
66 AbsBinds [] [] [(eq, eq)]
68 {-# LINE 2 "test3.hs" -}
70 eq :: PreludeBuiltin.Int -> PreludeBuiltin.Int -> PreludeCore.Bool
74 Main.Eq__INST_PreludeBuiltin.List =
79 _dict136 = {-singleDict-} _dict138
81 _dict129 = {-singleDict-} _dict136
82 AbsBinds [] [] [(eq, eq)]
86 Main.Eq__INST_PreludeBuiltin.List
87 [t135] [{-singleDict-} _dict136]
89 {-# LINE 5 "test3.hs" -}
91 eq :: [t135] -> [t135] -> PreludeCore.Bool
94 if (Main.null t135) xs then
98 if (Main.null t135) ys then
105 ((Main.Eq_.eq t135 _dict129)
116 (Main.Eq_.eq [t135] _dict133)
122 in ({-dict-} [] [eq])
123 Main.Ord__INST_PreludeBuiltin.Int =
126 _dict142 = Main.Eq__INST_PreludeBuiltin.Int [] []
127 AbsBinds [] [] [(gt, gt)]
129 {-# LINE 16 "test3.hs" -}
131 gt :: PreludeBuiltin.Int -> PreludeBuiltin.Int -> PreludeCore.Bool
133 in ({-dict-} [_dict142] [gt])
135 Main.Eq_.eq = /\ a -> \{-classdict-} [] [eq] -> eq
137 Main.Ord_.gt = /\ a -> \{-classdict-} [_dict56] [gt] -> gt
139 Main.Ord__TO_Main.Eq_ = /\ a -> \{-classdict-} [_dict58] [gt] -> ???_dict58???
141 AbsBinds [t60] [] [(hd, Main.hd)]
147 hd (a PreludeBuiltin.: as)
150 AbsBinds [t68] [] [(tl, Main.tl)]
157 tl (a PreludeBuiltin.: as)
161 AbsBinds [t91] [_dict85, _dict88] [(search, Main.search)]
163 {-# LINE 19 "test3.hs" -}
166 search :: t91 -> [t91] -> PreludeCore.Bool
171 if (Main.Ord_.gt t91 _dict85) ((Main.hd t91) bs) a then
175 if (Main.Eq_.eq t91 _dict88) a ((Main.hd t91) bs) then
179 search a ((Main.tl t91) bs)
180 AbsBinds [] [] [(and, Main.and)]
182 and :: PreludeCore.Bool -> PreludeCore.Bool -> PreludeCore.Bool
183 and PreludeCore.True PreludeCore.True
185 AbsBinds [] [] [(ordIntGt, Main.ordIntGt)]
187 _dict97 = PreludeCore.Num_INST_PreludeBuiltin.Int [] []
189 _dict98 = PreludeCore.Eq_INST_PreludeBuiltin.Int [] []
191 _dict100 = PreludeCore.Num_INST_PreludeBuiltin.Int [] []
193 _dict101 = PreludeCore.Eq_INST_PreludeBuiltin.Int [] []
198 ordIntGt :: PreludeBuiltin.Int -> PreludeBuiltin.Int -> PreludeCore.Bool
200 2 3 = PreludeCore.True
201 AbsBinds [] [] [(eqIntEq, Main.eqIntEq)]
203 _dict105 = PreludeCore.Num_INST_PreludeBuiltin.Int [] []
205 _dict106 = PreludeCore.Eq_INST_PreludeBuiltin.Int [] []
207 _dict108 = PreludeCore.Num_INST_PreludeBuiltin.Int [] []
209 _dict109 = PreludeCore.Eq_INST_PreludeBuiltin.Int [] []
212 eqIntEq :: PreludeBuiltin.Int -> PreludeBuiltin.Int -> PreludeCore.Bool
214 2 3 = PreludeCore.True
217 AbsBinds [t112] [] [(null, Main.null)]
220 null :: [t112] -> PreludeCore.Bool
221 null [] = PreludeCore.True