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
<Andrew.Butterfield@scss.tcd.ie> 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... :-)
--------------------------------------------------------------------
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/
--------------------------------------------------------------------