[Haskell-cafe] Is there a tutorial interpreter to teach haskell?
cppljevans at suddenlink.net
Tue Nov 30 18:08:14 CET 2010
By tutorial interpreter, I means something like
an expert system having a list of rules and than
a problem which is solved by using those list of
rules. The tutorial means the trace of the
"problem state" before and after
each rule is applied along with which parts
of the rule are matched with which part of the
"problem state". W.R.T. haskell, the "problem
state" would be a haskell expression and each "rule
application" would be simply reducing the haskell expression
(using some rule, which would be cited during the reduction)
to a simpler form until the final answer was achieved.
Obviously the rule applications to be trace should be
user selectable to avoid way too much output, but that
seems similar to setting breakpoints in selected functions;
hence, I guess it wouldn't be hard to do.
The attached file illustrates what I'm after.
I laboriously composed that attached to enable me
to understand what the haskell code was doing.
It would help other novices if such a trace could be
I'm currently trying to understand:
sequence (c:cs) = return (:) `ap` c `ap` sequence cs
from p. 2 of:
and again I'm having a lot of difficulty what the code is
doing. So far I've got:
Prelude Monad> :t ap
ap :: (Monad m) => m (a -> b) -> m a -> m b
Prelude Monad> :t return (:)
return (:) :: (Monad m) => m (a -> [a] -> [a])
Prelude Monad> (:) 'a' "bc"
Prelude Monad> :t return (:) `ap` "a"
return (:) `ap` "a" :: [[Char] -> [Char]]
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]
IOW, is it choice 1: in the above table for choice 2:?
I'd guess, since application associates to the left, that
it's choice 1:. But you see, I'm not sure, and I have to
work too hard to figure it all out. I *may* get it
eventually, but it's a *lot* of work.
I tutorial interpreter would make this so much easier!
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3267 bytes
Desc: not available
More information about the Haskell-Cafe