[Haskell-cafe] ANNOUNCE: lenses -- Simple Functional Lenses
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
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.
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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe