<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> modifyConfig :: (Config -> a) -> (a -> a) -> Config -> Config<br>
modifyConfig fr fv a = a { fr = fv (fr a) <br></blockquote><div><br></div><div>I like this Idea. The only problem I see is this: if I'm trying to write code that is very generic and abstract, how does the compiler know if the update</div>
<div><br>> a { fr = 5 }</div><div><br>is targeting a field fr of the record a, or a variable fr, which is in scope and "points to" a first-class field. The difference depends on the record in question, so the code would work differently depending on the context. I would think it would have to be something like </div>
<div><br>> a { :fr = 5 } </div><div><br>or something else syntactically distinct from current record update syntax.</div><div><br></div><div>With this and a few more conveniences on record syntax, lenses could go away. For example, I'd love to see a "lambda update" syntax. For example instead of:<br>
<br>> setName n r = r {name = n}</div><div><br></div><div>we'd write<br><br>> setName n = \{name = n}<br><br>I'd also like to see an "Update field by" syntax. Instead of <br><br>> addMr r = r { name = "Mr. " ++ (name r) }<br>
<br>we'd write <br><br>> addMr r = r { name => ("Mr. "++) }<br><br>or combining the previous 2:<br><br>> addMr = \{name=>("Mr. "++)}</div><div><br></div><div>feels very terse and "Haskelly" to me.</div>
<div><br></div><div>Regards,</div><div><br></div><div>--J Arthur</div><div><br></div><div><br></div></div>