simplified import of lens-family
Go to file
2014-05-19 18:18:20 -04:00
examples added pong.hs 2014-04-27 00:56:13 -04:00
Lens hiding (Fold) 2014-05-19 17:47:25 -04:00
lens-simple.cabal first commit 2014-04-26 23:21:13 -04:00
LICENSE first commit 2014-04-26 23:21:13 -04:00
README.md readme 2014-05-19 18:18:20 -04:00
Setup.hs first commit 2014-04-26 23:21:13 -04:00

lens-simple

This just re-exports the combinators and elementary 'van Laarhoven' lenses from Russell O'Connor's sublime lens-family package, including "Lens.Family2.State.Strict". lens-family has a complex structure and distinctly unpleasant module names, so I made this for my own use, but maybe with experience it will prove to be a sensible idea -- or not. It is mostly just intended to simplify imports for use with pipes and associated pipes libraries. The special quasi-lenses that pervade these libraries frequently require, at a minimum, that some version of view/(^.) and zoom should be in scope. (The effect of import Lens.Simple is at the moment a bit like that of import Control.Lens; presumably much more should be hidden!)

Because we are using the Rank2Types version, this requires ghc of course; the only non-boot library lens-family and lens-family-core require is mtl.
The naming in lens-family is more or less uniform with the more powerful and elaborate lens library, so it can be dropped in favor of lens should this become necessary.

Note the separate lens-family-th package.


The pong example from lens/examples is included here as an illustration of the strenth of lens-families + lens-families-th. Apart from the change of imports we are missing only the (<~) operator (just as well if we are planning on using pipes), so the only substantive change is to replace

reset = do
  ballPos .= (0, 0)
  ballSpeed <~ nextSpeed

with

reset = do
  ballPos .= (0, 0)
  s <- nextSpeed
  ballSpeed .= s