On Tue, Nov 30, 2010 at 12:08 PM, Larry Evans <span dir="ltr"><<a href="mailto:cppljevans@suddenlink.net">cppljevans@suddenlink.net</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
so now I must "manually" figure out what the a and b in<br>
the ap declaration correspond to in the return(:) type:<br>
<br>
m ( a -> b )<br>
__ _ _<br>
1: [] Char -> [Char]->[Char]<br>
2: [] Char->[Char] -> [Char]<br>
<br></blockquote><div>A type a -> b -> c is always equivalent to the type a -> (b->c), not (a->b) -> c.<br><br>In particular, breaking down sequence (c:cs) = return (:) `ap` c `ap` sequence cs<br>
<br> return (:) :: m (a -> [a] ->[a])<br> (\c -> return (:) `ap` c) :: m a -> m ([a] -> [a])<br> (\c cs' -> return (:) `ap` c `ap` cs') :: m a -> m [a] -> m [a]<br><br>therefore<br><br> sequence :: [ m a ] -> m [a] <br>
<br>Perhaps a special tutorial interpreter would be of use, but I've had some success simply passing in anonymous functions to ghci's :t operator, since that lets me simplify a program one bit at a time, inferring the types that might confuse me.<br>
</div></div>