packages feed

Kleislify 0.0.1 → 0.0.3

raw patch · 2 files changed

+44/−16 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Control.Kleislify: (->^) :: Functor f => (b -> f c) -> (c -> d) -> b -> f d
+ Control.Kleislify: (<-^) :: Functor f => (c -> f d) -> (b -> c) -> (b -> f d)
+ Control.Kleislify: (^->) :: Functor f => (b -> c) -> (c -> f d) -> b -> f d
+ Control.Kleislify: (^<-) :: Functor f => (c -> d) -> (b -> f c) -> b -> f d

Files

Control/Kleislify.hs view
@@ -7,34 +7,60 @@ -- Maintainer  :  dylan@techtangents.com -- Stability   :  experimental -- Portability :  portable--- --- Variants of Control.Arrow functions, specialised to kleislis. +--+-- Precomposition and postcomposition of functors and monads.+--+-- Variants of Control.Arrow functions, specialised to kleislis. -- Avoids boxing into Kleisli values. + module Control.Kleislify where +import Control.Applicative import Control.Arrow -infixr 1 ^=>, =>^-infixr 1 ^<=, <=^+infixr 1 ^=>, =>^, ^<=, <=^+infixr 1 ^->, ->^, ^<-, <-^ --- | Kleisli precomposition of a monad with a pure function. +-- | precomposition of a monad with a pure function. --   Equivalent to 'Control.Arrow.^>>'-(^=>) :: Monad m => (b -> c)  -> (c -> m d) -> b -> m d -(^=>) f k = runKleisli $ f ^>> (Kleisli k)+--   Equivalent to 'flip (.)'+(^=>) :: Monad m => (b -> c) -> (c -> m d) -> b -> m d+(^=>) = flip (.) --- | Kleisli postcomposition of a monad with a pure function. +-- | precomposition of a functor with a pure function.+--   Equivalent to 'flip (.)'+(^->) :: Functor f => (b -> c) -> (c -> f d) -> b -> f d+(^->) = flip (.)++-- | postcomposition of a monad with a pure function. --   Equivalent to 'Control.Arrow.>>^' (=>^) :: Monad m => (b -> m c) -> (c -> d) -> b -> m d-(=>^) k f = runKleisli $ Kleisli k >>^ f+k =>^ fn = \b -> return . fn =<< k b --- | Kleisli precomposition of a monad with a pure function (right-to-left variant). +-- | postcomposition of a functor with a pure function.+--   Equivalent to 'Control.Arrow.>>^'+(->^) :: Functor f => (b -> f c) -> (c -> d) -> b -> f d+k ->^ fn = (fmap fn) . k++-- | precomposition of a monad with a pure function (right-to-left variant). --   Equivalent to 'Control.Arrow.<<^'+--   Equivalent to '.' (<=^) :: Monad m => (c -> m d) -> (b -> c) -> (b -> m d)-(<=^) = flip (^=>)+(<=^) = (.) --- | Kleisli postcomposition of a monad with a pure function (right-to-left variant).+-- | precomposition of a functor with a pure function (right-to-left variant).+--   Equivalent to 'Control.Arrow.<<^'+--   Equivalent to '.'+(<-^) :: Functor f => (c -> f d) -> (b -> c) -> (b -> f d)+(<-^) = (.)++-- | postcomposition of a monad with a pure function (right-to-left variant). --   Equivalent to 'Control.Arrow.^<<' (^<=) :: Monad m => (c -> d) -> (b -> m c) -> b -> m d (^<=) = flip (=>^) +-- | postcomposition of a functor with a pure function (right-to-left variant).+--   Equivalent to 'Control.Arrow.^<<'+(^<-) :: Functor f => (c -> d) -> (b -> f c) -> b -> f d+(^<-) = flip (->^)
Kleislify.cabal view
@@ -1,13 +1,15 @@ Name:               Kleislify-Version:            0.0.1+Version:            0.0.3 Author:             Dylan Just <dylan@techtangents.com> License:            BSD3 License-file:       LICENSE Copyright:          Dylan Just Maintainer:         Dylan Just Category:           Control-Synopsis:           Variants of Control.Arrow functions, specialised to kleislis. -Description:        Avoids boxing into Control.Arrow.Kleisli values. +Synopsis:           Variants of Control.Arrow functions, specialised to kleislis.+Description:        Precomposition and postcomposition of functors and monads.+                    Variants of Control.Arrow functions, specialised to kleislis.+                    Avoids boxing into Kleisli values. Cabal-version:      >= 1.6 Build-Type:         Simple @@ -25,4 +27,4 @@                     -fno-warn-type-defaults                     -fno-warn-name-shadowing -  Exposed-Modules:  Control.Kleislify +  Exposed-Modules:  Control.Kleislify