Wish list: expanded defaulting, dependent types, reflection
Mike Gunter
m@ryangunter.com
29 Sep 2001 17:07:13 -0700
> >There does not seem to be a way to do everything I'd like in GHC even
> >in its most permissive mode (I'm using "-fallow-overlapping-instances
> >-fallow-undecidable-instances".) In particular, I'd like to use bare
> >integer literals together with values of the types I define.
>
> Do you have a code example of what you're trying to do?
Here's a simple example of the problem:
class Add a b c | a b -> c where add :: a -> b -> c
instance Add Integer Integer Integer where add = (+)
pt1 = (3::Integer) `add` (4::Integer) -- Works fine,
--ft2 = (5::Integer) `add` 6 -- Fails
mike
If you uncomment ft2, GHC (as expected) says:
/home/gunter/haskell/hdl/PlusTest.hs:20:
No instance for `Add Integer b c'
arising from use of `add' at /home/gunter/haskell/hdl/PlusTest.hs:20
in the definition of function `ft2': (5 :: Integer) `add` 6
/home/gunter/haskell/hdl/PlusTest.hs:20:
Ambiguous type variable(s) `b' in the constraint `Num b'
arising from the literal `6' at /home/gunter/haskell/hdl/PlusTest.hs:20
In the second argument of `add', namely `6'