packages feed

lens-simple 0.1.0.3 → 0.1.0.4

raw patch · 3 files changed

+102/−57 lines, 3 filesdep +transformers

Dependencies added: transformers

Files

LICENSE view
@@ -1,5 +1,5 @@-Copyright 2012,2013,2014 Russell O'Connor-Copyright (c) 2014, michaelt+Copyright (c) 2012,2013,2014 Russell O'Connor+Copyright (c) 2015, michaelt  All rights reserved. 
Lens/Simple.hs view
@@ -1,54 +1,70 @@-{-#LANGUAGE CPP #-}+{-#LANGUAGE CPP, RankNTypes #-} module Lens.Simple (-    -- * Stock Lenses-    _1, _2-    , chosen-    , ix-    , at, intAt-    , contains, intContains-    -    -- * Stock Traversals-    , both+    -- * Fundamental lens combinators (@view\/(^.)@,  @set\/(.~)@, @over\/(%~)@)+    view+    , set+    , over++    -- * Characteristic lenses (@_1@, @_2@) and traversals (@_Left@, @_Right@ etc.)+    , _1+    , _2     , _Left, _Right     , _Just, _Nothing-    , ignored+    , both     -    -- * Basic lens combinators-    , to, view, (^.)-    , folding, views, (^..), (^?)-    , toListOf, allOf, anyOf, firstOf, lastOf, sumOf, productOf-    , lengthOf, nullOf-    , backwards-    , over, (%~), set, (.~)-    , (&)-    , (??)     -    -- * Pseudo-imperatives-    , (+~), (*~), (-~), (//~), (&&~), (||~), (<>~)-    -    -- * State related combinators+    -- * Lens (etc.) formers+    , lens+    , iso+    , setting+    , to++    -- * Basic state related combinators: @zoom@, @use@, @assign\/(.=)@ etc.     , zoom     , use, uses+    , assign+    +    -- * Commonly used operators: particularly @view\/(^.)@,  @set\/(.~)@, @over\/(%~)@+    , (^.)+    , (%~)+    , (.~)+    , (&)+    , (??)+    , (?~)+    , (^..)+    , (^?)+    +    -- * Convenient state-related operators      , (%=)-    , assign, (.=)+    , (.=)     , (%%=)     , (<~)     -    -- * Compound state assignments-    , (+=), (-=), (*=)-    , (//=)-    , (&&=), (||=)-    , (<>=)+    -- * Pseudo-imperatives+    , (+~), (*~), (-~), (//~), (&&~), (||~), (<>~)     -    -- * Stock Semantic Editor Combinators++     -- * Corresponding state-related imperatives+    , (+=), (-=), (*=), (//=), (&&=), (||=), (<>=)+    +    -- * Stock semantic editor combinators (setters)     , mapped     -    -- * Lens formers-    , lens-    , iso-    , setting+    -- * More stock lenses +    , chosen+    , ix+    , at, intAt+    , contains, intContains     -    -- * Combining Combinators+    -- * More stock traversals +    , ignored+++    -- * Other combinators+    , folding, views+    , toListOf, allOf, anyOf, firstOf, lastOf, sumOf, productOf+    , lengthOf, nullOf+    , backwards     , choosing     , alongside     , beside@@ -58,15 +74,18 @@     , makeTraversals     , makeLensesBy     , makeLensesFor-    -- * Types     +    -- * Types+    , Lens, Lens'+    , Traversal, Traversal'+    , Getter, Getter'+    , Setter, Setter'     , LensLike, LensLike'     , FoldLike, FoldLike'-    , ASetter, ASetter'     , Phantom-    , Constant, Identity+    , Constant (..), Identity (..)     , AlongsideLeft, AlongsideRight-    , Zooming+    , Zooming           -- * Re-exports     , Monoid(..),(<>)@@ -76,11 +95,13 @@ import Lens.Family2.State.Strict import Lens.Family2.TH (makeLenses, makeTraversals, makeLensesBy, makeLensesFor) import Data.Monoid+import Data.Functor.Identity+import Data.Functor.Constant #if MIN_VERSION_base(4,8,0) import Data.Function ((&))-import Lens.Family hiding (Fold,(&))+import Lens.Family2 hiding ((&)) #else-import Lens.Family hiding (Fold)+import Lens.Family2  #endif  infixl 1 ??@@ -92,3 +113,6 @@ (??) :: Functor f => f (a -> b) -> a -> f b ff ?? a = fmap ($ a) ff {-# INLINE (??) #-}+--+(?~) :: Setter a a' b (Maybe b') -> b' -> a -> a'+l ?~ b = set l (Just b)
lens-simple.cabal view
@@ -1,5 +1,5 @@ name:                lens-simple-version:             0.1.0.3+version:             0.1.0.4 synopsis:            simplified import of elementary lens-family combinators  description:         This module, <http://hackage.haskell.org/package/lens-simple/docs/Lens-Simple.html Lens.Simple>, @@ -10,29 +10,49 @@                      other TH incantations from Dan Burton's associated                       <http://hackage.haskell.org/package/lens-family-th 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                      .-                     namely:+                     to wit, the elegant and spritely:                      .                      > import Lens.Simple                      .                      Check it out, it's even one character shorter!                       .-                     As an illustration of the power of even these elementary combinators, note that the +                     If you are unfamiliar with the use of what O'Connor calls van Laarhoven +                     lenses, you might take a +                     look at the excellent <http://www.serpentine.com/wreq/tutorial.html tutorial> +                     for the <http://hackage.haskell.org/package/wreq 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                       <https://github.com/michaelt/lens-family-simple/blob/master/examples/Pong.hs pong example> -                     from the @lens@ library requires only this abbreviating change of imports. -                     If you care to make that program more complicated, you might at some point need +                     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@. -                     Because @lens-family@ accords as -                     far as possible, with @Control.Lens@, within its more limited sphere,-                     a change of imports will often be all that is necessary to begin using them.+                     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.                      .-                     It is rarely necessary to exceed the materials exported here when using-                     the lenses and quasi-lenses exported by e.g. +                     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                      <http://hackage.haskell.org/package/pipes-bytestring pipes-bytestring> -                     or <http://hackage.haskell.org/package/pipes-group pipes-group>. It is simplify-                     the use of such that this module was originally intended.+                     and <http://hackage.haskell.org/package/pipes-group 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: @@ -47,7 +67,7 @@ license-file:        LICENSE author:              michaelt maintainer:          what_is_it_to_do_anything@yahoo.com-copyright:           Copyright (C) 2012,2013,2014 Russell O'Connor, 2014 michaelt+copyright:           2012, 2013, 2014 Russell O'Connor; 2015 Michael Thompson category:            Lenses      build-type:          Simple extra-source-files:  README.md@@ -59,6 +79,7 @@ library   exposed-modules:     Lens.Simple   build-depends:       base >= 4       && < 5+                       , transformers < 4.3                        , lens-family == 1.2.*                        , lens-family-core == 1.2.*                        , lens-family-th == 0.4.*