<div dir="ltr">Here's what I have so far for JoinList.hs:   (<a href="http://www.seas.upenn.edu/~cis194/spring13/hw/07-folds-monoids.pdf">http://www.seas.upenn.edu/~cis194/spring13/hw/07-folds-monoids.pdf</a>)<br><div><br>====<br>module JoinList<br><br>where<br><br>import Data.Monoid<br>import Sized<br><br>data JoinList m a = Empty<br>                  | Single m a<br>                  | Append m (JoinList m a) (JoinList m a)<br>     deriving (Eq, Show)<br><br><br>tag :: Monoid m => JoinList m a -> m<br>tag Empty           = mempty<br>tag (Single m a)    = m<br>tag (Append m  _ _) = m<br><br>(+++) :: Monoid m => JoinList m a -> JoinList m a -> JoinList m a<br>(+++) x y = Append (tag x <> tag y) x y<br><br><br>indexJ :: (Sized b, Monoid b) => Int -> JoinList b a -> Maybe a<br>indexJ _ Empty  = Nothing<br>indexJ i (Single m a) <br>    | i == 0    = Just a<br>    | otherwise = Nothing<br>indexJ i (Append m x y)<br>    | (getSize (tag x)) >= i  = indexJ i x<br>    | otherwise               = indexJ (i - (getSize (tag x))) y<br><br>=====<br><br></div><div>Here is the error I'm getting.   Haven't been able to make sense of it yet.<br><br>*Sized> :load "JoinList.hs"<br>[1 of 2] Compiling Sized            ( Sized.hs, interpreted )<br>[2 of 2] Compiling JoinList         ( JoinList.hs, interpreted )<br><br>JoinList.hs:50:21:<br>    Could not deduce (b ~ Size)<br>    from the context (Sized b, Monoid b)<br>      bound by the type signature for<br>                 indexJ :: (Sized b, Monoid b) => Int -> JoinList b a -> Maybe a<br>      at JoinList.hs:44:11-63<br>      `b' is a rigid type variable bound by<br>          the type signature for<br>            indexJ :: (Sized b, Monoid b) => Int -> JoinList b a -> Maybe a<br>          at JoinList.hs:44:11<br>    Expected type: JoinList Size a<br>      Actual type: JoinList b a<br>    In the first argument of `tag', namely `x'<br>    In the first argument of `getSize', namely `(tag x)'<br>    In the first argument of `(>=)', namely `(getSize (tag x))'<br>Failed, modules loaded: Sized.<br clear="all"></div><div><br><br><br></div><div>thanks!<br></div><div><br>-- <br><div class="gmail_signature">Dustin Lee<br>qhfgva=rot13(dustin)</div>
</div></div>