Looks to me that this should be ok.  GHC typechecks it fine.

Simon

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

_______________________________________________
Hugs-Bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/hugs-bugs

Reply via email to