[Haskell-cafe] About code style ?

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Mon Feb 1 21:37:12 EST 2010


zaxis <z_axis at 163.com> writes:
> However, i donot know how to write pure function using C style.
> func1 a = {
>   -- ...;
>    a * 2;
>   -- ...;
> }

You mean imperatively?  Short answer: you can't and you shouldn't.

Slightly longer answer: you can possibly fudge something together using
the Identity monad from mtl, but that will involve wrapping/unwrapping
everywhere.

Learn to think about how to chain/group functions together to form more
of a "pipeline" rather than a sequence of statements.  Haskell =/= C.

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list