[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hugs-bugs
Subject:    RE: possible bug
From:       "Simon Peyton-Jones" <simonpj () microsoft ! com>
Date:       2001-05-03 8:42:06
Message-ID: 37DA476A2BC9F64C95379BF66BA26902D72E96 () red-msg-09 ! redmond ! corp ! microsoft ! com
[Download RAW message or body]

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

Simon

| -----Original Message-----
| From: Jonathon Bell [mailto:jbell@mathsoft.com] 
| Sent: 18 April 2001 19:20
| To: 'hugs-bugs@haskell.org'
| 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 jbell@mathsoft.com
| MathSoft, Inc.  www.mathsoft.com
| 101 Main St, Cambridge, MA 02142
| (617) 577-1017 x745
| 
| 
| _______________________________________________
| Hugs-Bugs mailing list
| Hugs-Bugs@haskell.org 
| http://www.haskell.org/mailman/listinfo/hugs-bugs
| 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic