type synonyms/fun deps

Iavor Diatchki <[email protected]>
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Message-ID <[email protected]>
hello,

there seems to be something wrong with the
implementation of functional dependencies,
or perhaps the expansion of type synonyms.
i am using hugs from july 2003.  the program:

 > module Test where
 >
 > class C a b | a -> b where
 >  mk :: IO a
 >  eq :: a -> a -> IO Bool
 >
 > type F = IO
 >
 > instance C a x => C [a] (F a)
 >
 > test ys = do x  <- mk
 >              xs <- mk
 >              eq ys (x:xs)

causes the error:

ERROR "test.lhs":18 - Constraints are not consistent with functional 
dependency
*** Constraint       : C [a] (IO a a)
*** And constraint   : C [a] (F a)
*** For class        : C a b
*** Break dependency : a -> b

if 'type F = IO' is replaced with 'type F a = IO a' one gets
*** Constraint       : C [a] (IO [a])

if i inline the definition of 'F' things seem to work.

if i remove the assumption on the instance:
*** Constraint       : C [a] (b a)

if i remove the assumption on the instance, and eta-expand the type synonym:
*** Constraint       : C [a] (IO (IO a))

bye
iavor

-- 
==================================================
| Iavor S. Diatchki, Ph.D. student               |
| Department of Computer Science and Engineering |
| School of OGI at OHSU                          |
| http://www.cse.ogi.edu/~diatchki               |
==================================================
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.