possible bug
Simon Peyton-Jones
simonpj@microsoft.com
Thu, 3 May 2001 01:42:06 -0700
Looks to me that this should be ok. GHC typechecks it fine.
Simon
| -----Original Message-----
| From: Jonathon Bell [mailto:jbell@mathsoft.com]=20
| Sent: 18 April 2001 19:20
| To: 'hugs-bugs@haskell.org'
| Subject: possible bug
|=20
|=20
| Hello there,
|=20
| I've been experimenting with the use of type dependencies in=20
| type classes and have come across something i find=20
| surprising. Could it in fact be a bug in the implementation?=20
| I'm using Hugs Feb 2001, with switches +o and -98:
|=20
| > class Bug f a r | f a -> r where
| >
| > bug::f->a->r
| >
| > instance Bug (Int->r) Int r
| >--instance ...
| > instance (Bug f a r) =3D> Bug f (c a) (c r)=20
| >
| > f:: Bug(Int->Int) a r =3D> a->r
| > f =3D bug(id::Int->Int)
|=20
| The above compiles fine and at the prompt ..
|=20
| Main> f (f [0::Int])
|=20
| ...runs with an expected program error that member 'bug' has=20
| not been defined. Fine. But
|=20
| Main> f (f (f [0::Int]))
|=20
| -- ...fails to compile with an unresolved overloading:
|=20
| *** ERROR - Unresolved overloading
| *** Type : (Bug (Int->Int) Int a, Bug(Int->Int) a v =3D> [b]
| *** Expression : f (f (f [0]))
|=20
| which is a surprise. it appears as though the compiler is=20
| failing to exploit the dependency '|f a->r' from which it=20
| could infer that 'a' in the above message must in fact be=20
| 'Int', etc...
|=20
| Many thanks for investigating this...
|=20
| ________________________________
| Jonathon Bell jbell@mathsoft.com
| MathSoft, Inc. www.mathsoft.com
| 101 Main St, Cambridge, MA 02142
| (617) 577-1017 x745
|=20
|=20
| _______________________________________________
| Hugs-Bugs mailing list
| Hugs-Bugs@haskell.org=20
| http://www.haskell.org/mailman/listinfo/hugs-bugs
|=20