[Haskell-cafe] Is there a tutorial interpreter to teach haskell?
Noah Easterly
noah.easterly at gmail.com
Tue Nov 30 22:45:27 CET 2010
On Tue, Nov 30, 2010 at 12:08 PM, Larry Evans <cppljevans at suddenlink.net>wrote:
>
> so now I must "manually" figure out what the a and b in
> the ap declaration correspond to in the return(:) type:
>
> m ( a -> b )
> __ _ _
> 1: [] Char -> [Char]->[Char]
> 2: [] Char->[Char] -> [Char]
>
> A type a -> b -> c is always equivalent to the type a -> (b->c), not (a->b)
-> c.
In particular, breaking down sequence (c:cs) = return (:) `ap` c `ap`
sequence cs
return (:) :: m (a -> [a] ->[a])
(\c -> return (:) `ap` c) :: m a -> m ([a] -> [a])
(\c cs' -> return (:) `ap` c `ap` cs') :: m a -> m [a] -> m [a]
therefore
sequence :: [ m a ] -> m [a]
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20101130/5c3a92d3/attachment.htm>
More information about the Haskell-Cafe
mailing list