Unexpected "unresolved top-level overloading" error
Magnus Carlsson
magnus@cse.ogi.edu
Tue, 16 Apr 2002 14:01:08 -0700
The following module
module Bug where
class C a b c | a b -> c where
m :: a -> b -> c
instance C Integer Integer Integer
newtype T a = T a
instance C a b c => C (T a) (T b) (T c)
i :: T Integer
i = undefined
x = m (m i i) i
generates the following error:
$ hugs -98 Bug.hs
__ __ __ __ ____ ___ _________________________________________
|| || || || || || ||__ Hugs 98: Based on the Haskell 98 standard
||___|| ||__|| ||__|| __|| Copyright (c) 1994-2001
||---|| ___|| World Wide Web: http://haskell.org/hugs
|| || Report bugs to: hugs-bugs@haskell.org
|| || Version: December 2001 _________________________________________
Hugs mode: Restart with command line option +98 for Haskell 98 mode
Reading file "/usr/share/hugs/lib/Prelude.hs":
Reading file "Bug.hs":
Type checking
ERROR "Bug.hs":16 - Unresolved top-level overloading
*** Binding : x
*** Outstanding context : C Integer Integer b
If the definition of x is changed to
x _ = m (m i i) i
the module loads and x gets the type
Bug> :t x
x :: a -> T Integer
So it looks like a monomorphism check is carried out too early in the
first case.
/M