[Haskell-beginners] multi parameter classes and instance declarations

Markus Barenhoff alios at alios.org
Mon Feb 16 09:28:53 EST 2009


Good Afternoon,

i'am trying to express something like this here:

> -- CI.hs http://pastebin.com/f5b17cf57
> {-# OPTIONS -XMultiParamTypeClasses #-}

> module CI(D,f) where

> class B b

> class (B b) => A a b where
>     f :: b

> data D = D

> instance B D

> instance A D D where
>     f = D
> -- CI.hs

> -- MultiClassTest.hs http://pastebin.com/f1c481e8d
> import CI 

> a = f
> -- MultiClassTest.hs

ghc output:
MultiClassTest.hs:4:4:
    No instance for (CI.A a D)
      arising from a use of `f' at MultiClassTest.hs:4:4
    Possible fix: add an instance declaration for (CI.A a D)
    In the expression: f
    In the definition of `a': a = f
Failed, modules loaded: CI.

when opening MultiClassTest.hs it looks like the instance declaration gets
not important, but I think it might have a reson, that the ghc rejects that
code...

Regards
Markus  

-- 
Markus Barenhoff - MÃŒnster Germany,Europe,Earth
sip:alios at alios.org  - iax2:alios at alios.org - xmpp:alios at jabber.ccc.de 
gpg:0xAE7C7759 fp:79 64 AA D9 B7 16 F5 06  6A 88 5F A9 4D 49 45 BB 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 479 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/beginners/attachments/20090216/314acda6/attachment.bin


More information about the Beginners mailing list