type synonym or fun dep problem
Iavor Diatchki
diatchki at cse.ogi.edu
Tue Sep 16 14:08:54 EDT 2003
apologies if this gets to the list twice.
---
hello,
there seems to be something wrong with the
implementation of functional dependencies,
or perhaps the expansion of type synonyms.
i am using hugs (september 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 |
==================================================
More information about the Hugs-Bugs
mailing list