RE: Bug with fun-deps

"Simon Peyton-Jones" <[email protected]>
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Message-ID <036EAC76E7F5EC4996A3B3C3657D411601C4746D@EUR-MSG-21.europe.corp.microsoft.com>
I've added this as a GHC test too!  (typecheck/should_compile/tc187)

| -----Original Message-----
| From: [email protected]
[mailto:[email protected]] On Behalf Of Iavor
| Diatchki
| Sent: 19 February 2005 01:19
| To: [email protected]
| 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
| [email protected]
| http://www.haskell.org/mailman/listinfo/hugs-bugs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.