Re: [Haskell-cafe] Using lenses

2013-10-03 Thread AntC
> > Lenses for nested ... types ... > Hi Simon/Edward/all, The most compelling uses I've seen for lenses is back to Benjamin Pierce's [et al] papers on "Updatable Views". I think this is where the 'theory' started(?), although similar ideas had kicked around the relational database world for

Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Christopher Done
On 3 October 2013 10:57, Roman Cheplyaka wrote: > An interesting use case is my time-lens library. > http://hackage.haskell.org/package/time-lens-0.3/docs/Data-Time-Lens.html > > You can do things like > > >>> modL minutes (+5) (TimeOfDay 16 57 13) > 17:02:13 > > But one has to be somewhat len

Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Niklas Haas
On Thu, 3 Oct 2013 22:06:22 +1000, Tony Morris wrote: > Lenses for nested sum types e.g. Either. I think those would be leaning more in the direction of prisms. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listin

Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Tony Morris
Lenses for nested sum types e.g. Either. On 03/10/2013 6:08 PM, "Simon Peyton-Jones" wrote: > (I sent this to ‘libraries’ but Kim-Ee suggested adding Café, where so > many smart people hang out.) > > ** ** > > Friends > > ** ** > > Some of you will know that I’ve promised to give a talk

Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Gergely Risko
Hi Simon, http://hackage.haskell.org/package/lens-datetime-0.2/docs/Data-Time-Lens.html Read the top of the page. aDay = fromGregorian 2013 08 22 aLocal = LocalTime aDay (TimeOfDay 13 45 28) aUTC = UTCTime aDay 7458.9 >>> aLocal ^. years 2013 >>> aUTC ^. months 8 >>> aDay ^. days 22 >>> aLocal

Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Niklas Haas
Another great use of lenses is the lens-aeson library (not to be confused with aeson-lens). It's technically based around prisms, though, so it's outside the scope of your talk; but you may wish to at least reference it - it makes working with JSON really elegant! __

Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Sebastiaan Visser
Simon, I've used lenses to manipulate URIs represented as strings in a structured way, like: modify (port . iso parsePrintUri) (+10) "http://localhost:8070/index.html"; Of course using fclabels and not lens ;-) Sebastiaan On Oct 3, 2013, at 10:07 AM, Simon Peyton-Jones wrote: > (I sent th

Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Mike Ledger
Hi, In a game I made recently, I had to load OBJ formatted models into an OpenGL-friendly format. To do that, I'd parse the .obj, into a simple ADT, and build the model into a vector. Here's where lens comes in: we want to build separate vectors for the vertices, normals, UVs and faces indices. le

Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Roman Cheplyaka
Hi Simon, An interesting use case is my time-lens library. http://hackage.haskell.org/package/time-lens-0.3/docs/Data-Time-Lens.html You can do things like >>> modL minutes (+5) (TimeOfDay 16 57 13) 17:02:13 But one has to be somewhat lenient about the lens laws here. Roman * Simon Peyton

Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Nicolas Trangez
Simon, On Thu, 2013-10-03 at 08:07 +, Simon Peyton-Jones wrote: > If you are using the lens library yourself, could you spare a few minutes to tell me how you are using it? I'm not a heavy 'lens'-user (yet), and this might not be the most pretty use-case from a theoretic point of view, but an