lens-simple: simplified import of elementary lens-family combinators
This module, Lens.Simple,
just re-exports the main modules from Russell O'Connor's
lens-family
package, the original van Laarhoven lens library.
Lens.Simple also re-exports makeLenses and
other TH incantations from Dan Burton's associated
lens-family-th.
The idea is just to make a sort of low-powered, minimal-dependency lens-family equivalent of
the 800 lb gorilla of lens library imports:
import Control.Lens
to wit, the elegant and spritely:
import Lens.Simple
Check it out, it's even one character shorter!
If you are unfamiliar with the use of what O'Connor calls van Laarhoven
lenses, you might take a
look at the excellent tutorial
for the wreq
library. All of the tutorial material will compile if you replace
import Control.Lens with the suave import Lens.Simple.
The error messages you get might be a little less opaque. But
the point is basically academic, of course: you have already weighed down your
sandbox with the lens library by installing wreq and if you get
any deeper into wreq you will need it.
As another illustration of the simplicity of the
fundamental van Laarhoven lens combinators, note that the gloss
pong example
from the lens library examples directory requires only this
abbreviating change of imports.
If you care to make that program more complicated,
you might at some point need
the unfathomably more sophisticated material in Control.Lens.
Within its more limited sphere, lens-family accords as
far as possible with lens, so this switch
will often be all that is necessary to begin using them.
This module was originally intended to simplify the use of packages that
follow the original promise of the van Laarhoven lenses. Correct practice is
to export lenses without depending on a lens-library, where possible;
in basic cases these use just familiar Prelude types.
Examples of best practices in this respect are
pipes-bytestring
and pipes-group.
Because of the heavily monadic character of those libraries, the
extra material in Control.Lens is rarely of use anyway; one sticks largely
to view/(^.), set/(.~), over/(%~) and zoom.
Note that many of the other lenses and combinators are a bit more
specialized than their Control.Lens equivalents:
for example, _1 and _2 are here
familiarly specialized to act just on real Haskell
pairs. With the loss of abstraction we also of course
lose the concomitant opaque error messages
about Field1 s t a b etc.
[Skip to Readme]
Downloads
- lens-simple-0.1.0.4.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
| Versions [RSS] | 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 0.1.0.6, 0.1.0.7, 0.1.0.8, 0.1.0.9 |
|---|---|
| Dependencies | base (>=4 && <5), lens-family (>=1.2 && <1.3), lens-family-core (>=1.2 && <1.3), lens-family-th (>=0.4 && <0.5), transformers (<4.3) [details] |
| License | BSD-3-Clause |
| Copyright | 2012, 2013, 2014 Russell O'Connor; 2015 Michael Thompson |
| Author | michaelt |
| Maintainer | what_is_it_to_do_anything@yahoo.com |
| Category | Lenses |
| Home page | https://github.com/michaelt/lens-simple |
| Source repo | head: git clone https://github.com/michaelt/lens-simple |
| Uploaded | by MichaelThompson at 2015-06-10T20:41:05Z |
| Distributions | |
| Reverse Dependencies | 8 direct, 46 indirect [details] |
| Downloads | 9011 total (23 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating | |
| Status | Docs uploaded by user Build status unknown [no reports yet] |