[Hugs-bugs] Bug with fun-deps

Simon Peyton-Jones simonpj at microsoft.com
Wed Feb 23 04:20:25 EST 2005


I've added this as a GHC test too!  (typecheck/should_compile/tc187)

| -----Original Message-----
| From: hugs-bugs-bounces at haskell.org
[mailto:hugs-bugs-bounces at haskell.org] On Behalf Of Iavor
| Diatchki
| Sent: 19 February 2005 01:19
| To: hugs-bugs at haskell.org
| Subject: [Hugs-bugs] Bug with fun-deps
| 
| 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
| _______________________________________________
| Hugs-Bugs mailing list
| Hugs-Bugs at haskell.org
| http://www.haskell.org/mailman/listinfo/hugs-bugs


More information about the Hugs-Bugs mailing list