[Haskell-cafe] ANNOUNCE: lenses -- Simple Functional Lenses

Job Vranish jvranish at gmail.com
Thu Sep 3 09:34:10 EDT 2009

Actually they are _not_ limited to only the state monad, they just work
naturally there. There are a few functions that allow you to easily use them
outside a state monad (fetch, update, alter).

It looks like the haddock documentation is generated now. There are a couple
simple examples for accessing nested state in the tutorial in the module
documentation here:

Would a more complex example be helpful? I don't have time to post one now,
but perhaps in an hour or two.

Yeah, I decided to go with the state monad over making my own mathematically
beautiful datatype.  The state monad worked just too well all by itself. It
also has the advantage of not really needed any helper functions (other than
fromGetSet). All the important ones are already exist.

- Job

On Thu, Sep 3, 2009 at 5:50 AM, Martijn van Steenbergen <
martijn at van.steenbergen.nl> wrote:

> Job Vranish wrote:
>> A simple but powerful implementation of function lenses (aka functional
>> references, accessors, etc..).
> Nice! I will definitely give it a whirl when I pick up my MUD again. I'm
> currently using accessors there. I see your functions are limited to use in
> the state monad--you're right, I've never used accessors outside of a state
> monad yet.
> I'm somewhat sad that you didn't capture lenses in a datatype, because it
> is such a nice example of a Category instance. I would like to see how to
> compose lenses to access deeper fields--I use nested data structures and
> would like to modify fields that are hidden deeper in the state. Can you
> perhaps add an example to show that?
> Thanks!
> Martijn.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090903/4cf05491/attachment.html

More information about the Haskell-Cafe mailing list