Is there a tutorial interpreter to teach haskell?

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 automated. I'm currently trying to understand: sequence (c:cs) = return (:) `ap` c `ap` sequence cs from p. 2 of: http://www.soi.city.ac.uk/~ross/papers/Applicative.pdf and again I'm having a lot of difficulty what the code is doing. So far I've got: --{--eshell-- 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" "abc" Prelude Monad> :t return (:) `ap` "a" return (:) `ap` "a" :: [[Char] -> [Char]] --}--eshell-- 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! -regards, Larry

On Tue, Nov 30, 2010 at 12:08 PM, Larry Evans
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.

Andy Gill developed HERA which sounds somewhat similar to what you are asking, but I don't know that it would be particularly beginner friendly and I think it was static - i.e. the reduction rules were applied to program source code rather than within an interactive evaluation of a running program. I thought I'd seen more information about it on the web, but all I can seem to find at the moment is this page: http://www.haskell.org/haskellwiki/Haskell_Equational_Reasoning_Assistant Maybe a debugger like HOOD or HAT would be usefully illustrative for runtime evaluation? I think HOOD is back working with recent GHC's.

On 11/30/10 16:46, Stephen Tetley wrote:
Andy Gill developed HERA which sounds somewhat similar to what you are asking, but I don't know that it would be particularly beginner friendly and I think it was static - i.e. the reduction rules were applied to program source code rather than within an interactive evaluation of a running program. I thought I'd seen more information about it on the web, but all I can seem to find at the moment is this page:
http://www.haskell.org/haskellwiki/Haskell_Equational_Reasoning_Assistant
[snip] Thanks for that link Stephen, unfortunately when I, as instructed by that link, did: darcs get http://code.haskell.org/HERA and then, as instructed by the just gotten HERA/README, did: make boot I got errors as shown in the attachment. I did post these results on the HERA discussion page: http://www.haskell.org/haskellwiki /Talk:Haskell_Equational_Reasoning_Assistant However, apparently I didn't post it right because it's all formatted wrong, making it hard to read :( -regards, Larry
participants (3)
-
Larry Evans
-
Noah Easterly
-
Stephen Tetley