
2008/2/15 Antoine Latter
(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: http://en.wikibooks.org/wiki/Haskell/Advanced_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 from_seq seq | 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