kleisli 0.0.1 → 0.0.2
raw patch · 3 files changed
+36/−1 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Kleisli: pureContraKleisli :: forall (p :: Type -> Type -> Type) (g :: Type -> Type) x a. (Profunctor p, Applicative g) => ContraKleisli' p x a -> ContraKleisli p x g a
+ Data.Kleisli: pureKleisli :: forall (p :: Type -> Type -> Type) (g :: Type -> Type) a x. (Profunctor p, Applicative g) => Kleisli' p a x -> Kleisli p a g x
+ Data.Kleisli: pureProKleisli :: forall (p :: Type -> Type -> Type) (g :: Type -> Type) a x. (Profunctor p, Applicative g) => ProKleisli' p a x -> ProKleisli p g a x
Files
- changelog.md +5/−0
- kleisli.cabal +1/−1
- src/Data/Kleisli.hs +30/−0
changelog.md view
@@ -1,3 +1,8 @@+0.0.2++* Add `pureKleisli`, `pureProKleisli`, `pureContraKleisli` for lifting+ Identity-based Kleisli values into an arbitrary Applicative functor+ 0.0.1 * This change log starts
kleisli.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: kleisli-version: 0.0.1+version: 0.0.2 synopsis: Kleisli-like newtypes with different type parameter orderings description: Three newtype wrappers around @p a (f b)@ with different type parameter
src/Data/Kleisli.hs view
@@ -62,10 +62,13 @@ -- * Functor layer mapping hoistKleisli, hoistKleisli',+ pureKleisli, hoistProKleisli, hoistProKleisli',+ pureProKleisli, hoistContraKleisli, hoistContraKleisli',+ pureContraKleisli, ) where @@ -313,6 +316,15 @@ hoistKleisli' h = hoistKleisli (h . runIdentity) {-# INLINE hoistKleisli' #-} +-- | Lift a 'Kleisli'' (with 'Identity' as the functor) into an arbitrary+-- 'Applicative' functor using 'pure'.+--+-- >>> let Kleisli f = pureKleisli (Kleisli (Identity . (+1)) :: Kleisli' (->) Int Int) :: Kleisli (->) Int Maybe Int in f 5+-- Just 6+pureKleisli :: (Profunctor p, Applicative g) => Kleisli' p a x -> Kleisli p a g x+pureKleisli = hoistKleisli' pure+{-# INLINE pureKleisli #-}+ -- | Map over the functor layer of a 'ProKleisli' using 'rmap'. -- -- >>> let ProKleisli f = hoistProKleisli (Just . runIdentity) (ProKleisli (Identity . (+1)) :: ProKleisli (->) Identity Int Int) in f 5@@ -330,6 +342,15 @@ hoistProKleisli' h = hoistProKleisli (h . runIdentity) {-# INLINE hoistProKleisli' #-} +-- | Lift a 'ProKleisli'' (with 'Identity' as the functor) into an arbitrary+-- 'Applicative' functor using 'pure'.+--+-- >>> let ProKleisli f = pureProKleisli (ProKleisli (Identity . (+1)) :: ProKleisli' (->) Int Int) :: ProKleisli (->) Maybe Int Int in f 5+-- Just 6+pureProKleisli :: (Profunctor p, Applicative g) => ProKleisli' p a x -> ProKleisli p g a x+pureProKleisli = hoistProKleisli' pure+{-# INLINE pureProKleisli #-}+ -- | Map over the functor layer of a 'ContraKleisli' using 'rmap'. -- -- >>> let ContraKleisli f = hoistContraKleisli (Just . runIdentity) (ContraKleisli (Identity . (+1)) :: ContraKleisli (->) Int Identity Int) in f 5@@ -346,6 +367,15 @@ hoistContraKleisli' :: (Profunctor p) => (b -> g c) -> ContraKleisli' p b a -> ContraKleisli p c g a hoistContraKleisli' h = hoistContraKleisli (h . runIdentity) {-# INLINE hoistContraKleisli' #-}++-- | Lift a 'ContraKleisli'' (with 'Identity' as the functor) into an arbitrary+-- 'Applicative' functor using 'pure'.+--+-- >>> let ContraKleisli f = pureContraKleisli (ContraKleisli (Identity . (+1)) :: ContraKleisli' (->) Int Int) :: ContraKleisli (->) Int Maybe Int in f 5+-- Just 6+pureContraKleisli :: (Profunctor p, Applicative g) => ContraKleisli' p x a -> ContraKleisli p x g a+pureContraKleisli = hoistContraKleisli' pure+{-# INLINE pureContraKleisli #-} -- | >>> import Control.Lens (op, _Wrapped') -- >>> op Kleisli (Kleisli Just :: Kleisli (->) Int Maybe Int) 5