[Hugs-bugs] Bug with fun-deps
Iavor Diatchki
iavor.diatchki at gmail.com
Fri Feb 18 20:18:43 EST 2005
Hello,
I seem to have run into a problem involving functional dependencies.
Below is an excerpt of a program I was writing that illustrates the bug.
> data N0
> newtype Succ n = Succ n
> class Plus a b c | a b -> c
> instance Plus N0 n n
> instance Plus a b c => Plus (Succ a) b (Succ c)
> ( # ) :: Plus x y z => x -> y -> z
> ( # ) = undefined
> class BitRep t n | t -> n where
> toBits :: t -> n
> instance BitRep Bool (Succ N0)
> instance BitRep (Bool,Bool,Bool) (Succ (Succ (Succ N0))) where
> toBits (x,y,z) =
The program works with the line below, but if I remove it
I get a type error --- Hugs complains that it cannot solve
the constraint:
Plus (Succ N0) (Succ N0) (Succ (Succ N0))
> toBits' where toBits' =
> toBits x
> # toBits y
> # toBits z
The program works with GHC in either form, and it looks like
Hugs should be able to solve the constraint using the instances above.
-Iavor
More information about the Hugs-Bugs
mailing list