[Haskell] FunDeps and MArray

Remi Turk rturk at science.uva.nl
Mon Sep 5 17:24:50 EDT 2005


On Mon, Sep 05, 2005 at 11:31:00AM -0700, Scherrer, Chad wrote:
> I keep getting this error in GHCi:
> 
> Illegal instance declaration for `PlusEq (a i e) (a i e) (m ())'
>     (the instance types do not agree with the functional dependencies of the class)
>     In the instance declaration for `PlusEq (a i e) (a i e) (m ())'
> Failed, modules loaded: none.
> 
> Looking at GHC's documentation for MArray, the definition starts out
> 
> class (HasBounds a, Monad m) => MArray a e m where
> ...
> 
> It seems to me if MArray were written using fundeps (something like
> MArray a e m | a e -> m) things may work out. Is there a reason it's not
> written this way? If so, is there another way to do what I'm trying to
> do? Thanks.

I don't know the actual reason, but if it were MArray a e m | a e -> m
it would be impossible to define an MArray instance of STArray
for both the strict and the lazy ST monad.
(There isn't currently an instance for the lazy ST monad, but
right now it can easily be defined:
http://www.mail-archive.com/haskell-cafe@haskell.org/msg09404.html)

Groetjes,

Remi

-- 
Nobody can be exactly like me. Even I have trouble doing it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell/attachments/20050905/3146041d/attachment.bin


More information about the Haskell mailing list