packages feed

microlens-mtl 0.1.11.1 → 0.2.1.1

raw patch · 5 files changed

Files

CHANGELOG.md view
@@ -1,3 +1,28 @@+# 0.2.1.1++* Bump version for microlens 0.5.++# 0.2.1.0++* Export `Zoomed` type family.++# 0.2.0.3++* [#161](https://github.com/stevenfontanella/microlens/pull/161) Fix GHC 9.4 warning for using `~` without TypeOperators+* [#162](https://github.com/stevenfontanella/microlens/pull/162) Fix GHC warning for depending on StarIsType++# 0.2.0.2++* Added support for mtl 2.3 and transformers 0.6 per [#152](https://github.com/stevenfontanella/microlens/issues/152).++# 0.2.0.1++* No more conditional `Safe` (see [#122](https://github.com/monadfix/microlens/issues/122)).++# 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,35 +1,49 @@ name:                microlens-mtl-version:             0.1.11.1+version:             0.2.1.1 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/stevenfontanella/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:          Steven Fontanella <steven.fontanella@gmail.com>+homepage:            http://github.com/stevenfontanella/microlens+bug-reports:         http://github.com/stevenfontanella/microlens/issues+-- copyright: category:            Data, Lenses build-type:          Simple extra-source-files:   CHANGELOG.md cabal-version:       >=1.10+tested-with:+                     GHC==9.12.1+                     GHC==9.10.1+                     GHC==9.8.4+                     GHC==9.6.6+                     GHC==9.4.8+                     GHC==9.2.8+                     GHC==9.0.2+                     GHC==8.10.7+                     GHC==8.8.4+                     GHC==8.6.5+                     GHC==8.4.4+                     GHC==8.2.2+                     GHC==8.0.2  source-repository head   type:                git-  location:            git://github.com/aelve/microlens.git+  location:            https://github.com/stevenfontanella/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-                     , transformers >=0.2 && <0.6+                     , microlens >=0.5 && <0.6+                     , mtl >=2.0.1 && <2.4+                     , transformers >=0.2 && <0.7                      , transformers-compat >=0.4 && <1    ghc-options:@@ -39,3 +53,4 @@    hs-source-dirs:      src   default-language:    Haskell2010+  default-extensions:  TypeOperators
src/Lens/Micro/Mtl.hs view
@@ -12,7 +12,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@@ -39,6 +39,7 @@   (<<%=), (<<.=),    -- * Zooming+  Zoomed,   zoom,   magnify, )@@ -119,13 +120,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 +138,8 @@ s &~ l = execState l s {-# INLINE (&~) #-} +infixl 1 &~+ {- | Modify state by “assigning” a value to a part of the state. @@ -159,6 +155,8 @@ l .= x = State.modify (l .~ x) {-# INLINE (.=) #-} +infix 4 .=+ {- | A synonym for ('.='). -}@@ -179,6 +177,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 +192,8 @@ l <~ mb = mb >>= (l .=) {-# INLINE (<~) #-} +infixr 2 <~+ {- | Modify state by applying a function to a part of the state. An example: @@ -217,6 +219,8 @@ l %= f = State.modify (l %~ f) {-# INLINE (%=) #-} +infix 4 %=+ {- | A synonym for ('%='). -}@@ -241,18 +245,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 +278,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 +294,8 @@ l <<%= f = l %%= (\a -> (a, f a)) {-# INLINE (<<%=) #-} +infix 4 <<%=+ {- | Set state and return the old value. @@ -294,6 +310,8 @@ l <<.= b = l %%= (\a -> (a, b)) {-# INLINE (<<.=) #-} +infix 4 <<.=+ {- | Set state and return new value. @@ -307,6 +325,8 @@ l <.= b = l <%= const b {-# INLINE (<.=) #-} +infix 4 <.=+ {- | ('<?=') is a version of ('<.=') that wraps the value into 'Just' before setting. @@ -321,6 +341,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
@@ -9,6 +9,9 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE Trustworthy #-}+#if !MIN_VERSION_base(4, 9, 0)+{-# LANGUAGE DataKinds #-}+#endif  -- This is needed because ErrorT is deprecated. {-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}@@ -16,7 +19,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'.@@ -51,6 +54,10 @@   import Control.Applicative+#if MIN_VERSION_mtl(2, 3, 0)+import Control.Monad (liftM, liftM2)+#else+#endif import Control.Monad.Reader as Reader import Control.Monad.State as State import Control.Monad.Trans.State.Lazy as Lazy@@ -59,9 +66,11 @@ import Control.Monad.Trans.Writer.Strict as Strict import Control.Monad.Trans.RWS.Lazy as Lazy import Control.Monad.Trans.RWS.Strict as Strict+#if !MIN_VERSION_transformers(0, 6, 0) import Control.Monad.Trans.Error-import Control.Monad.Trans.Except import Control.Monad.Trans.List+#endif+import Control.Monad.Trans.Except import Control.Monad.Trans.Identity import Control.Monad.Trans.Maybe -- microlens@@ -72,13 +81,21 @@ import Data.Monoid #endif +#if MIN_VERSION_base(4,9,0)+import Data.Kind (Type)+#endif + ------------------------------------------------------------------------------ -- Zoomed ------------------------------------------------------------------------------  -- | This type family is used by 'Zoom' to describe the common effect type.+#if MIN_VERSION_base(4,9,0)+type family Zoomed (m :: Type -> Type) :: Type -> Type -> Type+#else type family Zoomed (m :: * -> *) :: * -> * -> *+#endif type instance Zoomed (Strict.StateT s z) = Focusing z type instance Zoomed (Lazy.StateT s z) = Focusing z type instance Zoomed (ReaderT e m) = Zoomed m@@ -87,9 +104,11 @@ type instance Zoomed (Lazy.RWST r w s z) = FocusingWith w z type instance Zoomed (Strict.WriterT w m) = FocusingPlus w (Zoomed m) type instance Zoomed (Lazy.WriterT w m) = FocusingPlus w (Zoomed m)+#if !MIN_VERSION_transformers(0, 6, 0) type instance Zoomed (ListT m) = FocusingOn [] (Zoomed m)-type instance Zoomed (MaybeT m) = FocusingMay (Zoomed m) type instance Zoomed (ErrorT e m) = FocusingErr e (Zoomed m)+#endif+type instance Zoomed (MaybeT m) = FocusingMay (Zoomed m) type instance Zoomed (ExceptT e m) = FocusingErr e (Zoomed m)  ------------------------------------------------------------------------------@@ -256,7 +275,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). @@ -386,18 +405,20 @@   zoom l = Lazy.WriterT . zoom (\afb -> unfocusingPlus #. l (FocusingPlus #. afb)) . Lazy.runWriterT   {-# INLINE zoom #-} +#if !MIN_VERSION_mtl(2, 3, 0) && !MIN_VERSION_transformers(0, 6, 0) instance Zoom m n s t => Zoom (ListT m) (ListT n) s t where   zoom l = ListT . zoom (\afb -> unfocusingOn . l (FocusingOn . afb)) . runListT   {-# INLINE zoom #-} -instance Zoom m n s t => Zoom (MaybeT m) (MaybeT n) s t where-  zoom l = MaybeT . liftM getMay . zoom (\afb -> unfocusingMay #. l (FocusingMay #. afb)) . liftM May . runMaybeT-  {-# INLINE zoom #-}- instance (Error e, Zoom m n s t) => Zoom (ErrorT e m) (ErrorT e n) s t where   zoom l = ErrorT . liftM getErr . zoom (\afb -> unfocusingErr #. l (FocusingErr #. afb)) . liftM Err . runErrorT   {-# INLINE zoom #-}+#endif +instance Zoom m n s t => Zoom (MaybeT m) (MaybeT n) s t where+  zoom l = MaybeT . liftM getMay . zoom (\afb -> unfocusingMay #. l (FocusingMay #. afb)) . liftM May . runMaybeT+  {-# INLINE zoom #-}+ instance Zoom m n s t => Zoom (ExceptT e m) (ExceptT e n) s t where   zoom l = ExceptT . liftM getErr . zoom (\afb -> unfocusingErr #. l (FocusingErr #. afb)) . liftM Err . runExceptT   {-# INLINE zoom #-}@@ -409,7 +430,11 @@ ------------------------------------------------------------------------------  -- | This type family is used by 'Magnify' to describe the common effect type.+#if MIN_VERSION_base(4,9,0)+type family Magnified (m :: Type -> Type) :: Type -> Type -> Type+#else type family Magnified (m :: * -> *) :: * -> * -> *+#endif type instance Magnified (ReaderT b m) = Effect m type instance Magnified ((->)b) = Const type instance Magnified (Strict.RWST a w s m) = EffectRWS w s m@@ -422,7 +447,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).