[Haskell-cafe] A question about State Monad and Monad in general

C K Kashyap ckkashyap at gmail.com
Fri Jul 16 02:35:29 EDT 2010

Thanks Wren,

Thanks Dave ... a quick question though could you point me to an example
where I could build up my own in place modifiable data structure in Haskell
without using any standard library stuff?

For example, if I wanted an image representation such as this
[[(Int,Int.Int)]] - basically a list of lists of 3 tuples (rgb) and wanted
to do in place replacement to set the pixel values, how could I go about it.

On Fri, Jul 16, 2010 at 9:47 AM, wren ng thornton <wren at freegeek.org> wrote:

> C K Kashyap wrote:
>> Thanks Daniel,
>> Better refactorability.
>>> If you're using monadic style, changing from, say,
>>> State Thing
>>> to
>>> StateT Thing OtherMonad
>>> or from
>>> StateT Thing FirstMonad
>>> to
>>> StateT Thing SecondMonad
>>> typically requires only few changes. Explicit state-passing usually
>>> requires more changes.
>> So, performance gain (runtime/memory) is not a side effect of Monadic
>> style
>> right?
> Generally speaking, right: monadic style won't improve performance.
> However, using monadic notation may allow you to change the backing monad
> to a different representation of "the same" computation, thereby giving
> asymptotic improvements[1]. However, the improvements themselves are coming
> from the different representation; the use of monadic notation just allows
> you to switch the representation without altering the code.
> [1] http://www.iai.uni-bonn.de/~jv/mpc08.pdf<http://www.iai.uni-bonn.de/%7Ejv/mpc08.pdf>
> --
> Live well,
> ~wren
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100716/f0e86d48/attachment.html

More information about the Haskell-Cafe mailing list