packages feed

invariant 0.5.5 → 0.5.6

raw patch · 3 files changed

+35/−1 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Functor.Invariant: InvariantArrow :: c a a -> InvariantArrow c a
+ Data.Functor.Invariant: InvariantProfunctor :: p a a -> InvariantProfunctor p a
+ Data.Functor.Invariant: instance Control.Arrow.Arrow c => Data.Functor.Invariant.Invariant (Data.Functor.Invariant.InvariantArrow c)
+ Data.Functor.Invariant: instance Data.Profunctor.Unsafe.Profunctor p => Data.Functor.Invariant.Invariant (Data.Functor.Invariant.InvariantProfunctor p)
+ Data.Functor.Invariant: invmapArrow :: Arrow arr => (a -> b) -> (b -> a) -> arr a a -> arr b b
+ Data.Functor.Invariant: invmapProfunctor :: Profunctor p => (a -> b) -> (b -> a) -> p a a -> p b b
+ Data.Functor.Invariant: newtype InvariantArrow c a
+ Data.Functor.Invariant: newtype InvariantProfunctor p a

Files

CHANGELOG.md view
@@ -1,3 +1,9 @@+# 0.5.6 [2022.05.07]+* Add `InvariantProfunctor` and `InvariantArrow` newtypes that admit+  implementations of `invmap` that only require `Profunctor` or `Arrow`+  constraints, respectively. Also add top-level `invmapProfunctor` and+  `invmapArrow` functions.+ # 0.5.5 [2021.11.01] * Allow building with GHC 9.2. * Allow building with `transformers-0.6.*`.
invariant.cabal view
@@ -1,5 +1,5 @@ name:                invariant-version:             0.5.5+version:             0.5.6 synopsis:            Haskell98 invariant functors description:         Haskell98 invariant functors (also known as exponential functors).                      .
src/Data/Functor/Invariant.hs view
@@ -42,7 +42,11 @@ #endif   , WrappedFunctor(..)   , invmapContravariant+  , invmapProfunctor+  , invmapArrow   , WrappedContravariant(..)+  , InvariantProfunctor(..)+  , InvariantArrow(..)     -- * @Invariant2@   , Invariant2(..)   , invmap2Bifunctor@@ -195,6 +199,14 @@ invmapContravariant :: Contravariant f => (a -> b) -> (b -> a) -> f a -> f b invmapContravariant = const contramap +-- | A 'Profunctor' with the same input and output types can be seen as an 'Invariant' functor.+invmapProfunctor :: Profunctor p => (a -> b) -> (b -> a) -> p a a -> p b b+invmapProfunctor = flip dimap++-- | An 'Arrow' with the same input and output types can be seen as an 'Invariant' functor.+invmapArrow :: Arrow arr => (a -> b) -> (b -> a) -> arr a a -> arr b b+invmapArrow fn1 fn2 arrow = arr fn1 Cat.. arrow Cat.. arr fn2+ ------------------------------------------------------------------------------- -- Invariant instances -------------------------------------------------------------------------------@@ -986,3 +998,19 @@ genericInvmap :: (Generic1 f, Invariant (Rep1 f)) => (a -> b) -> (b -> a) -> f a -> f b genericInvmap f g = to1 . invmap f g . from1 #endif++-------------------------------------------------------------------------------+-- Wrappers+-------------------------------------------------------------------------------++-- | A 'Profunctor' with the same input and output types can be seen as an 'Invariant' functor.+newtype InvariantProfunctor p a = InvariantProfunctor (p a a)++instance Profunctor p => Invariant (InvariantProfunctor p) where+  invmap fn1 fn2 (InvariantProfunctor f) = InvariantProfunctor (invmapProfunctor fn1 fn2 f)++-- | An 'Arrow' with the same input and output types can be seen as an 'Invariant' functor.+newtype InvariantArrow c a = InvariantArrow (c a a)++instance Arrow c => Invariant (InvariantArrow c) where+  invmap fn1 fn2 (InvariantArrow arrow) = InvariantArrow (invmapArrow fn1 fn2 arrow)