[Haskell-beginners] purely functional (non-monadic) alternatives
for Haskell animations in _The Haskell School of Expression_?
chaddai.fouche at gmail.com
Wed Aug 13 08:25:54 EDT 2008
2008/8/13 Benjamin L. Russell <DekuDekuplex at yahoo.com>:
>>P.S. Yes, I have read Paul's book and I think Haskell has something
>>You may be surprised to learn, however, that world.ss animations are
>>purely functional while Haskell animations (in Paul's book) are actually
>>quasi-imperative. That is, they are using monads and carry the
>>on their sleeves.
> In response to this claim, does anybody know how to rewrite Hudak's
> SOE animations so that they do not use monads and are "purely
First, monad /= imperative
It is important to establish this distinction which doesn't seem to be
very clear in some minds...
The IO monad allows imperative actions, the ST monad too, the Maybe
Monad doesn't, neither does the List Monad... The State monad can be
argued either way but all it does is make easier to use a pattern you
often meet in non-monadic functional programming.
The confusion is helped along by the do-notation in Haskell which
definitely looks like imperative programming, but is only sugar over a
purely functional form.
Now, I don't know SOE very well and it is very possible that its
description of animation is imperative but animations imply to handle
time and order of operations anyway, so I don't really see how you
could implement that in a more purely functional style, a monad is
very good at describing ordered actions with a light syntax in a
(Another aspect is if the details of the rendering of the animation is
interleaved with the description, that is a more interesting subject,
on which we could compare the code in world.ss and SOE)
More information about the Beginners