Quoth Evan Laforge <qdun...@gmail.com>, > On Thu, Feb 9, 2012 at 12:49 PM, Donn Cave <d...@avvanta.com> wrote: ... >> For example, in a better world you could write stuff like >> >> modifyConfig :: (Config -> a) -> (a -> a) -> Config -> Config >> modifyConfig fr fv a = a { fr = fv (fr a) } >> >> upTempo config = modifyConfig tempo (+ 20) config > > I think lenses already do better than this, since not only are they > more concise than the above (once you've resigned yourself to a few TH > splices), they aren't restricted to being only record fields.
How more concise? Because =# is more concise than `modifyRecord', etc., or is there some real economy of expression I missed out on? Asking because, honestly I didn't get your earlier example - setTempo :: Config -> Config setTempo y = Config.deflt#Config.tempo =# y ... something's missing, I thought - but maybe it's conciser than I can reckon with! The rest - the functions that look like fields, the enforcing invariants, etc. - are cool as lens features, but for Haskell records in general it seems like something that would call for a lot of discussion. Compared to first class record update, where it's easy to see how close to broken the current situation is. Donn _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe