microlens-mtl 0.1.11.1 → 0.2.0
raw patch · 5 files changed
+68/−22 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Lens.Micro.Mtl.Internal: infixr 2 `magnify`
+ Lens.Micro.Mtl.Internal: instance (GHC.Base.Monad m, GHC.Base.Semigroup r) => GHC.Base.Semigroup (Lens.Micro.Mtl.Internal.Effect m r a)
+ Lens.Micro.Mtl.Internal: instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Lens.Micro.Mtl.Internal.Err e a)
+ Lens.Micro.Mtl.Internal: instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Lens.Micro.Mtl.Internal.May a)
+ Lens.Micro.Mtl.Internal: type family Magnified (m :: * -> *) :: * -> * -> *
- Lens.Micro.Mtl: (%=) :: (MonadState s m) => ASetter s s a b -> (a -> b) -> m ()
+ Lens.Micro.Mtl: (%=) :: MonadState s m => ASetter s s a b -> (a -> b) -> m ()
- Lens.Micro.Mtl: modifying :: (MonadState s m) => ASetter s s a b -> (a -> b) -> m ()
+ Lens.Micro.Mtl: modifying :: MonadState s m => ASetter s s a b -> (a -> b) -> m ()
- Lens.Micro.Mtl.Internal: class (Magnified m ~ Magnified n, MonadReader b m, MonadReader a n) => Magnify m n b a | m -> b, n -> a, m a -> n, n b -> m
+ Lens.Micro.Mtl.Internal: class (MonadReader b m, MonadReader a n) => Magnify m n b a | m -> b, n -> a, m a -> n, n b -> m
- Lens.Micro.Mtl.Internal: class (Zoomed m ~ Zoomed n, MonadState s m, MonadState t n) => Zoom m n s t | m -> s, n -> t, m t -> n, n s -> m
+ Lens.Micro.Mtl.Internal: class (MonadState s m, MonadState t n) => Zoom m n s t | m -> s, n -> t, m t -> n, n s -> m
Files
- CHANGELOG.md +4/−0
- LICENSE +3/−2
- microlens-mtl.cabal +17/−9
- src/Lens/Micro/Mtl.hs +35/−8
- src/Lens/Micro/Mtl/Internal.hs +9/−3
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.2.0++* Removed of equality constraints on `Zoom` and `Magnify`, as was done in `lens` earlier. This allows instances of `Zoom` and `Magnify` for `FreeT`. (Thanks to @treeowl.)+ # 0.1.11.1 * Fixed compilation on GHC 8.4.
LICENSE view
@@ -1,5 +1,6 @@ Copyright (c) 2013-2016 Edward Kmett,- 2015-2016 Artyom+ 2015-2016 Artyom Kazak,+ 2018 Monadfix All rights reserved. @@ -14,7 +15,7 @@ disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Artyom nor the names of other+ * Neither the name of Monadfix nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
microlens-mtl.cabal view
@@ -1,31 +1,39 @@ name: microlens-mtl-version: 0.1.11.1+version: 0.2.0 synopsis: microlens support for Reader/Writer/State from mtl description: This package contains functions (like 'view' or '+=') which work on 'MonadReader', 'MonadWriter', and 'MonadState' from the mtl package. .- This package is a part of the <http://hackage.haskell.org/package/microlens microlens> family; see the readme <https://github.com/aelve/microlens#readme on Github>.+ This package is a part of the <http://hackage.haskell.org/package/microlens microlens> family; see the readme <https://github.com/monadfix/microlens#readme on Github>. license: BSD3 license-file: LICENSE-author: Edward Kmett, Artyom-maintainer: Artyom <yom@artyom.me>-homepage: http://github.com/aelve/microlens-bug-reports: http://github.com/aelve/microlens/issues--- copyright: +author: Edward Kmett, Artyom Kazak+maintainer: Monadfix <hi@monadfix.io>+homepage: http://github.com/monadfix/microlens+bug-reports: http://github.com/monadfix/microlens/issues+-- copyright: category: Data, Lenses build-type: Simple extra-source-files: CHANGELOG.md cabal-version: >=1.10+tested-with: GHC==7.4.2+ GHC==7.6.3+ GHC==7.8.4+ GHC==7.10.3+ GHC==8.0.2+ GHC==8.2.2+ GHC==8.4.4+ GHC==8.6.4 source-repository head type: git- location: git://github.com/aelve/microlens.git+ location: git://github.com/monadfix/microlens.git library exposed-modules: Lens.Micro.Mtl Lens.Micro.Mtl.Internal- -- other-extensions: + -- other-extensions: build-depends: base >=4.5 && <5 , microlens >=0.4 && <0.5 , mtl >=2.0.1 && <2.3
src/Lens/Micro/Mtl.hs view
@@ -4,7 +4,13 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE TypeFamilies #-}++-- Lens.Micro.Internal is either Trustworthy or Unsafe+#if __GLASGOW_HASKELL__ >= 708+{-# LANGUAGE Safe #-}+#else {-# LANGUAGE Trustworthy #-}+#endif -- This is needed because ErrorT is deprecated. {-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}@@ -12,7 +18,7 @@ {- | Module : Lens.Micro.Mtl-Copyright : (C) 2013-2016 Edward Kmett, 2015-2016 Artyom+Copyright : (C) 2013-2016 Edward Kmett, 2015-2016 Artyom Kazak, 2018 Monadfix License : BSD-style (see the file LICENSE) -} module Lens.Micro.Mtl@@ -119,13 +125,6 @@ preuse l = State.gets (preview l) {-# INLINE preuse #-} --infix 4 .=, %=, ?=-infix 4 <<.=, <<%=, <%=, <.=, <?=-infix 4 +=, -=, *=, //=-infixr 2 <~-infixl 1 &~- {- | This can be used to chain lens operations using @op=@ syntax rather than @op~@ syntax for simple non-type-changing cases.@@ -144,6 +143,8 @@ s &~ l = execState l s {-# INLINE (&~) #-} +infixl 1 &~+ {- | Modify state by “assigning” a value to a part of the state. @@ -159,6 +160,8 @@ l .= x = State.modify (l .~ x) {-# INLINE (.=) #-} +infix 4 .=+ {- | A synonym for ('.='). -}@@ -179,6 +182,8 @@ l ?= b = l .= Just b {-# INLINE (?=) #-} +infix 4 ?=+ {- | ('<~') is a version of ('.=') that takes a monadic value (and then executes it and assigns the result to the lens). @@ -192,6 +197,8 @@ l <~ mb = mb >>= (l .=) {-# INLINE (<~) #-} +infixr 2 <~+ {- | Modify state by applying a function to a part of the state. An example: @@ -217,6 +224,8 @@ l %= f = State.modify (l %~ f) {-# INLINE (%=) #-} +infix 4 %=+ {- | A synonym for ('%='). -}@@ -241,18 +250,26 @@ l += x = l %= (+x) {-# INLINE (+=) #-} +infix 4 +=+ (-=) :: (MonadState s m, Num a) => ASetter s s a a -> a -> m () l -= x = l %= (subtract x) {-# INLINE (-=) #-} +infix 4 -=+ (*=) :: (MonadState s m, Num a) => ASetter s s a a -> a -> m () l *= x = l %= (*x) {-# INLINE (*=) #-} +infix 4 *=+ (//=) :: (MonadState s m, Fractional a) => ASetter s s a a -> a -> m () l //= x = l %= (/x) {-# INLINE (//=) #-} +infix 4 //=+ {- | Modify state and return the modified (new) value. @@ -266,6 +283,8 @@ l <%= f = l %%= (\a -> (a, a)) . f {-# INLINE (<%=) #-} +infix 4 <%=+ {- | Modify state and return the old value (i.e. as it was before the modificaton). @@ -280,6 +299,8 @@ l <<%= f = l %%= (\a -> (a, f a)) {-# INLINE (<<%=) #-} +infix 4 <<%=+ {- | Set state and return the old value. @@ -294,6 +315,8 @@ l <<.= b = l %%= (\a -> (a, b)) {-# INLINE (<<.=) #-} +infix 4 <<.=+ {- | Set state and return new value. @@ -307,6 +330,8 @@ l <.= b = l <%= const b {-# INLINE (<.=) #-} +infix 4 <.=+ {- | ('<?=') is a version of ('<.=') that wraps the value into 'Just' before setting. @@ -321,6 +346,8 @@ (<?=) :: MonadState s m => LensLike ((,) b) s s a (Maybe b) -> b -> m b l <?= b = l %%= const (b, Just b) {-# INLINE (<?=) #-}++infix 4 <?= (%%=) :: MonadState s m => LensLike ((,) r) s s a b -> (a -> (r, b)) -> m r #if MIN_VERSION_mtl(2,1,1)
src/Lens/Micro/Mtl/Internal.hs view
@@ -8,7 +8,13 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE KindSignatures #-}++-- Lens.Micro.Internal is either Trustworthy or Unsafe+#if __GLASGOW_HASKELL__ >= 708+{-# LANGUAGE Safe #-}+#else {-# LANGUAGE Trustworthy #-}+#endif -- This is needed because ErrorT is deprecated. {-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}@@ -16,7 +22,7 @@ {- | Module : Lens.Micro.Mtl.Internal-Copyright : (C) 2013-2016 Edward Kmett, 2015-2016 Artyom+Copyright : (C) 2013-2016 Edward Kmett, 2015-2016 Artyom Kazak, 2018 Monadfix License : BSD-style (see the file LICENSE) This module lets you define your own instances of 'Zoom' and 'Magnify'.@@ -256,7 +262,7 @@ infixr 2 `zoom` -class (Zoomed m ~ Zoomed n, MonadState s m, MonadState t n) => Zoom m n s t | m -> s, n -> t, m t -> n, n s -> m where+class (MonadState s m, MonadState t n) => Zoom m n s t | m -> s, n -> t, m t -> n, n s -> m where {- | When you're in a state monad, this function lets you operate on a part of your state. For instance, if your state was a record containing a @position@ field, after zooming @position@ would become your whole state (and when you modify it, the bigger structure would be modified as well). @@ -422,7 +428,7 @@ infixr 2 `magnify` -class (Magnified m ~ Magnified n, MonadReader b m, MonadReader a n) => Magnify m n b a | m -> b, n -> a, m a -> n, n b -> m where+class (MonadReader b m, MonadReader a n) => Magnify m n b a | m -> b, n -> a, m a -> n, n b -> m where {- | This is an equivalent of 'Reader.local' which lets you apply a getter to your environment instead of merely applying a function (and it also lets you change the type of the environment).