lenses

Functional lenses

纵然是瞬间 提交于 2019-11-26 15:13:10
问题 Could someone explain functional lenses to me? It's a surprisingly difficult subject to google for and I haven't made any progress. All I know is that they provide similar get/set functionality than in OO. 回答1: A lens consists of two functions, a getter and a setter: data Lens a b = Lens { getter :: a -> b, setter :: b -> a -> a } For example, we might have lenses for the first and second parts of a pair: fstLens :: Lens (a, b) a fstLens = Lens fst $ \x (a, b) -> (x, b) sndLens :: Lens (a, b)

lenses, fclabels, data-accessor - which library for structure access and mutation is better

白昼怎懂夜的黑 提交于 2019-11-26 13:57:55
There are at least three popular libraries for accessing and manipulating fields of records. The ones I know of are: data-accessor, fclabels and lenses. Personally I started with data-accessor and I'm using them now. However recently on haskell-cafe there was an opinion of fclabels being superior. Therefore I'm interested in comparison of those three (and maybe more) libraries. Edward KMETT There are at least 4 libraries that I am aware of providing lenses. The notion of a lens is that it provides something isomorphic to data Lens a b = Lens (a -> b) (b -> a -> a) providing two functions: a

lenses, fclabels, data-accessor - which library for structure access and mutation is better

谁说胖子不能爱 提交于 2019-11-26 03:46:30
问题 There are at least three popular libraries for accessing and manipulating fields of records. The ones I know of are: data-accessor, fclabels and lenses. Personally I started with data-accessor and I\'m using them now. However recently on haskell-cafe there was an opinion of fclabels being superior. Therefore I\'m interested in comparison of those three (and maybe more) libraries. 回答1: There are at least 4 libraries that I am aware of providing lenses. The notion of a lens is that it provides