RE: Anomalous Class Fundep Inference
At 2001-05-03 01:42, Simon Peyton-Jones wrote:
Quite right too!
OK, I understand it a bit better now. This code does not compile: -- class X a instance X Bool instance (Num a) => X a -- Can someone explain why the two instances overlap, given that Bool is not an instance of Num? Would it be possible for Haskell to figure out this sort of thing and not complain about it, or would that lead to nasty problems? -- Ashley Yakeley, Seattle WA
Ashley Yakeley <ashley@semantic.org> wrote
OK, I understand it a bit better now. This code does not compile: -- class X a instance X Bool instance (Num a) => X a -- Can someone explain why the two instances overlap, given that Bool is not an instance of Num?
Would it be possible for Haskell to figure out this sort of thing and not complain about it, or would that lead to nasty problems?
Think what would happen if someone had a module that did define Bool as an instance of Num and imported the class X. -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk 31 Chalmers Road jf@cl.cam.ac.uk Cambridge CB1 3SZ +44 1223 570179 (after 14:00 only, please!)
On Sat, 5 May 2001, Jon Fairbairn wrote:
Ashley Yakeley <ashley@semantic.org> wrote
OK, I understand it a bit better now. This code does not compile: -- class X a instance X Bool instance (Num a) => X a -- Can someone explain why the two instances overlap, given that Bool is not an instance of Num?
Would it be possible for Haskell to figure out this sort of thing and not complain about it, or would that lead to nasty problems?
Think what would happen if someone had a module that did define Bool as an instance of Num and imported the class X.
Program will be rejected at point of such import (or instance declaration)? More simple example: importing two different modules with the exactly same instance declarations for some type. Anton Moscal
participants (3)
-
Anton Moscal -
Ashley Yakeley -
Jon Fairbairn