I'm new to Haskell, but I do like your idea. I prefer this as a built-in feature because it will create a standard way of doing this, making the question "wich package should I use to get mutatos? lens-foo, lens-bar, monad-lens, lens-lens-foo-bar, ...?" simply go away.
So, yes, I up-vote your idea to write an official proposal. Thiago. 2012/8/2 Jonathan Geddes <[email protected]>: > > Richard O'Keefe Said: >>> Ouch! And that's not even very deeply nested. >>> Imagine 4 or 5 levels deep. It really makes >>> Haskell feel clunky next to `a.b.c.d = val` >>> that you see in other languages. >> >>I was taught that this kind of thing violates the Law of Demeter >>and that an object should not be mutating the parts of an >>acquaintance's parts, but should ask the acquaintance to do so. >>I'd say that a.b.c.d = val is at the very least a sign that >>some encapsulation did not happen. > > Absolutely! But in Haskell how do you do the > asking? I guess that's what I'm proposing is > a built in way of doing just that! I'm > shooting for as-easy-as the built in getters. > > Erik Hesselink said: >>Isn't this exactly the problem solved by all the lens packages? > > Yes it is. I think the existence of these > packages along with all the proposals to > change records is an indication that > something is missing from the language as a > whole. What I'm proposing is that the > language give you something that is > lightweight and easy to use to address this > issue. You can still use lenses on top of all > of this. > >> makeLens myField myField' > > If I remember correctly, one of the problems > with lenses is that they cannot support > polymorphic updates (updates which change a > type variable of the data). SEC functions, on > the other hand support polymorphic updates. > > --Jonathan > > On Thu, Aug 2, 2012 at 4:48 AM, Andrew Butterfield > <[email protected]> wrote: >> >> Ah yes - the joy of Haskell >> >> It so easy to roll your own, rather than search to find someone else's >> (better/more elegant) solution... :-) >> >> >> On 2 Aug 2012, at 11:41, Erik Hesselink wrote: >> >> > On Thu, Aug 2, 2012 at 12:30 PM, Andrew Butterfield >> > <[email protected]> wrote: >> >> >> >> On 2 Aug 2012, at 09:25, Erik Hesselink wrote: >> >> >> >>> Isn't this exactly the problem solved by all the lens packages? >> >>> Current popular ones are fclabels [0] and data-lens [1]. >> >>> >> >>> [0] http://hackage.haskell.org/package/fclabels >> >>> [1] http://hackage.haskell.org/package/data-lens >> >> >> >> Not sure what all of these do, but I have a simple solution I use >> >> in my work: >> > >> > They do exactly that. They create 'lenses' which are >> > getters/setters/modifiers combined, and allow you to compose these to >> > get/set/modify deep inside nested data types. Look at the examples in >> > the fclabels documentation [2] for more details. >> > >> > [2] >> > http://hackage.haskell.org/packages/archive/fclabels/1.1.4/doc/html/Data-Label.html >> >> -------------------------------------------------------------------- >> Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204 >> Lero@TCD, Head of Foundations & Methods Research Group >> Director of Teaching and Learning - Undergraduate, >> School of Computer Science and Statistics, >> Room G.39, O'Reilly Institute, Trinity College, University of Dublin >> http://www.scss.tcd.ie/Andrew.Butterfield/ >> -------------------------------------------------------------------- >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> [email protected] >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > [email protected] > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
