[Haskell-cafe] Help with error
jeff1.61803 at gmail.com
Sat Feb 16 04:06:48 EST 2008
2008/2/15 Antoine Latter <aslatter at gmail.com>:
> (sent to the list this time)
> The problem is in the type-signature for from_seq:
> from_seq :: (Sequence seq) => (seq e) -> (t e)
> Neither the From_seq class or the type signature of the from_seq
> function place any restrictions on the type of e, so the type can be
> rewritten as:
> from_seq :: forall e seq . Sequence seq => (seq e) -> (t e)
> That is, the class explicitly defines from_seq has having norestrictions
> on e.
> Your from_seq' function requires the type e (in the error, e1) to
> inhabit IArray a e.
> The IArray constraint isn't compatible with the From_seq class
> definition. You may need to explore multi-parameter type classes:
> Does this help?
Yes, this helped. I added the type variable, e, to my From_seq class and it
worked. Thank you for the explanation. Here are the changes I made:
class From_seq t e where
from_seq :: (Sequence seq) => (seq e) -> (t e)
instance From_seq  e where
| snull seq = 
| otherwise = (shead seq) : (from_seq (stail seq))
instance (Ix i, Num i, IArray a e) => From_seq (a i) e where
from_seq seq = from_seq' seq
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe