fclabels 1.0.5 → 1.1.0
raw patch · 4 files changed
+26/−15 lines, 4 filesdep ~template-haskelldep ~transformersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: template-haskell, transformers
API changes (from Hackage documentation)
+ Data.Label.PureM: (=.) :: MonadState s m => s :-> a -> (a -> a) -> m ()
Files
- fclabels.cabal +8/−7
- src/Data/Label/Derive.hs +4/−1
- src/Data/Label/Maybe.hs +2/−2
- src/Data/Label/PureM.hs +12/−5
fclabels.cabal view
@@ -1,5 +1,5 @@ Name: fclabels-Version: 1.0.5+Version: 1.1.0 Author: Sebastiaan Visser, Erik Hesselink, Chris Eidhof, Sjoerd Visscher. Synopsis: First class accessor labels. Description: This package provides first class labels that can act as@@ -19,10 +19,11 @@ . See the "Data.Label.Maybe" module for the use of partial labels. .- > 1.0.4 -> 1.0.5- > - Relaxed template-haskell dependency constraint for GHC 7.4- > - Relaxed transformers dependency constraint- > (thanks to Claude Heiland-Allen)+ > 1.0.4 -> 1.1.0+ > - Fixed error in derived code in combination with -XMonoLocalBinds.+ > - Lowered the priority of =: operator.+ > - Added the =. operator for modification in state monads.+ Maintainer: Sebastiaan Visser <code@fvisser.nl> License: BSD3 License-File: LICENCE@@ -46,9 +47,9 @@ GHC-Options: -Wall Build-Depends: base < 5- , template-haskell >= 2.2 && < 2.8+ , template-haskell >= 2.2 && < 2.7 , mtl >= 1.0 && < 2.2- , transformers >= 0.2 && < 0.4+ , transformers >= 0.2 && < 0.3 Source-Repository head Type: git
src/Data/Label/Derive.hs view
@@ -101,7 +101,7 @@ where mono = forallT prettyVars (return []) [t| $(inputType) :~> $(return prettyFieldtyp) |] poly = forallT forallVars (return []) [t| (ArrowChoice $(arrow), ArrowZero $(arrow)) => Lens $(arrow) $(inputType) $(return prettyFieldtyp) |]- body = [| let c = zeroArrow ||| returnA in lens (c . $(getter)) (c . $(setter)) |]+ body = [| lens (fromRight . $(getter)) (fromRight . $(setter)) |] where getter = [| arr (\ p -> $(caseE [|p|] (cases (bodyG [|p|] ) ++ wild))) |] setter = [| arr (\(v, p) -> $(caseE [|p|] (cases (bodyS [|p|] [|v|]) ++ wild))) |]@@ -149,6 +149,9 @@ function (s, b) = liftM2 (,) (sigD labelName s) (funD labelName [ clause [] (normalB b) [] ])++fromRight :: (ArrowChoice a, ArrowZero a) => a (Either b d) d+fromRight = zeroArrow ||| returnA -------------------------------------------------------------------------------
src/Data/Label/Maybe.hs view
@@ -53,8 +53,8 @@ modify :: (f :~> a) -> (a -> a) -> f -> Maybe f modify l m = run (A.modify l . arr (arr m,)) --- | Embed a pure lens that points to a `Maybe` field into--- a lens that might fail.+-- | Embed a pure lens that points to a `Maybe` field into a lens that might+-- fail. embed :: A.Lens (->) f (Maybe a) -> f :~> a embed l = lens (A.get l) (\a f -> Just (A.set l (Just a, f)))
src/Data/Label/PureM.hs view
@@ -6,6 +6,7 @@ , puts , modify , (=:)+, (=.) -- * 'MonadReader' lens operations. , asks@@ -28,17 +29,23 @@ puts :: M.MonadState s m => s :-> a -> a -> m () puts l = M.modify . L.set l +-- | Modify a value with a function somewhere in the state, pointed to by the+-- specified lens.++modify :: M.MonadState s m => s :-> a -> (a -> a) -> m ()+modify l = M.modify . L.modify l+ -- | Alias for `puts' that reads like an assignment. -infixr 7 =:+infixr 2 =: (=:) :: M.MonadState s m => s :-> a -> a -> m () (=:) = puts --- | Modify a value with a function somewhere in the state, pointed to by the--- specified lens.+-- | Alias for `modify' that reads more or less like an assignment. -modify :: M.MonadState s m => s :-> a -> (a -> a) -> m ()-modify l = M.modify . L.modify l+infixr 2 =.+(=.) :: M.MonadState s m => s :-> a -> (a -> a) -> m ()+(=.) = modify -- | Fetch a value pointed to by a lens out of a reader environment.