[Haskell-beginners] Translating imperative algorithms to Haskell

Tom Tobin korpios at korpios.com
Fri Feb 19 17:17:37 EST 2010

On Fri, Feb 19, 2010 at 4:10 PM, Mikhail Novikov <freiksenet at gmail.com> wrote:
> Maybe I should look into ST monad for this. :) I am still interested if there is a way to make this kind of functions in purely functional way.

I *think* the answer to your question is "no".  You can write
imperative code in Haskell (via ST and IO), and you can write
functional code that gets equivalent results to a given chunk of
imperative code, but you can't directly translate imperative code to
functional code, since they're two qualitatively different things.
It's like asking to express a square in terms of a circle -- you can
come up with a circle that has the same area, but it's definitely
*not* a square.  :-)

More information about the Beginners mailing list