<br><br><div class="gmail_quote">2008/2/15 Antoine Latter <<a href="mailto:aslatter@gmail.com">aslatter@gmail.com</a>>:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
(sent to the list this time)<br><div class="Ih2E3d"><br>The problem is in the type-signature for from_seq:<br><br></div><div class="Ih2E3d">from_seq :: (Sequence seq) => (seq e) -> (t e)<br><br></div><div class="Ih2E3d">
Neither the From_seq class or the type signature of the from_seq<br>function place any restrictions on the type of e, so the type can be<br>rewritten as:<br><br>from_seq :: forall e seq . Sequence seq => (seq e) -> (t e)<br>
<br>That is, the class explicitly defines from_seq has having norestrictions on e.<br><br>Your from_seq' function requires the type e (in the error, e1) to<br>inhabit IArray a e.<br><br>The IArray constraint isn't compatible with the From_seq class<br>
definition. You may need to explore multi-parameter type classes:<br><a href="http://en.wikibooks.org/wiki/Haskell/Advanced_type_classes" target="_blank">http://en.wikibooks.org/wiki/Haskell/Advanced_type_classes</a><br>
<br>Does this help?<br></div></blockquote></div><br>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:<br><br><span style="font-family: courier new,monospace;">class From_seq t e where</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> from_seq :: (Sequence seq) => (seq e) -> (t e)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">instance From_seq [] e where</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> from_seq seq </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> | snull seq = []</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> | otherwise = (shead seq) : (from_seq (stail seq))</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">instance (Ix i, Num i, IArray a e) => From_seq (a i) e where</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> from_seq seq = from_seq' seq</span><br style="font-family: courier new,monospace;"><br>