packages feed

composition-extra (empty) → 0.0.0.1

raw patch · 7 files changed

+194/−0 lines, 7 filesdep +basedep +contravariantsetup-changed

Dependencies added: base, contravariant

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2011-2012, Dan Burton++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Dan Burton nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ composition-extra.cabal view
@@ -0,0 +1,25 @@+name:                composition-extra+version:             0.0.0.1+synopsis:            Combinators for unorthodox structure composition++license:             BSD3+license-file:        LICENSE+author:              Athan Clark+maintainer:          athan.clark@gmail.com++category:            Data+build-type:          Simple+cabal-version:       >=1.8++library+  hs-source-dirs:      src+  exposed-modules:     Data.Functor.Composition+                       Data.Functor.Contravariant.Composition+                       Data.Function.Contravariant.Composition+                       Control.Monad.Composition+  build-depends:       base >= 4.6 && < 5+                     , contravariant++source-repository head+  type:     git+  location: git://github.com/athanclark/composition-extra.git
+ src/Control/Monad/Composition.hs view
@@ -0,0 +1,62 @@+module Control.Monad.Composition where++(>>==) :: Monad m =>+          m b+       -> (a -> b -> m c)+       -> a -> m c+(>>==) mb f a = f a =<< mb++(>>===) :: Monad m =>+           m c+        -> (a -> b -> c -> m d)+        -> a -> b -> m d+(>>===) mc f a b = f a b =<< mc++(>>====) :: Monad m =>+            m d+         -> (a -> b -> c -> d -> m e)+         -> a -> b -> c -> m e+(>>====) md f a b c = f a b c =<< md++(>>=====) :: Monad m =>+             m e+          -> (a -> b -> c -> d -> e -> m f)+          -> a -> b -> c -> d -> m f+(>>=====) me f a b c d = f a b c d =<< me++(>>======) :: Monad m =>+              m f+           -> (a -> b -> c -> d -> e -> f -> m g)+           -> a -> b -> c -> d -> e -> m g+(>>======) mf f a b c d e = f a b c d e =<< mf+++(==<<) :: Monad m =>+          (a -> b -> m c)+       -> m b+       -> a -> m c+(==<<) = flip (>>==)++(===<<) :: Monad m =>+           (a -> b -> c -> m d)+        -> m c+        -> a -> b -> m d+(===<<) = flip (>>===)++(====<<) :: Monad m =>+            (a -> b -> c -> d -> m e)+         -> m d+         -> a -> b -> c -> m e+(====<<) = flip (>>====)++(=====<<) :: Monad m =>+             (a -> b -> c -> d -> e -> m f)+          -> m e+          -> a -> b -> c -> d -> m f+(=====<<) = flip (>>=====)++(======<<) :: Monad m =>+              (a -> b -> c -> d -> e -> f -> m g)+           -> m f+           -> a -> b -> c -> d -> e -> m g+(======<<) = flip (>>======)
+ src/Data/Function/Contravariant/Composition.hs view
@@ -0,0 +1,16 @@+module Data.Function.Contravariant.Composition where++(-.) :: (a -> b) -> (b -> c) -> a -> c+(-.) g f a = f $ g a++(-.:) :: (b -> c) -> (a -> c -> d) -> a -> b -> d+(-.:) g f a b = f a $ g b++(-.::) :: (c -> d) -> (a -> b -> d -> e) -> a -> b -> c -> e+(-.::) g f a b c = f a b $ g c++(-.:::) :: (d -> e) -> (a -> b -> c -> e -> f) -> a -> b -> c -> d -> f+(-.:::) g f a b c d = f a b c $ g d++(-.::::) :: (e -> f) -> (a -> b -> c -> d -> f -> g) -> a -> b -> c -> d -> e -> g+(-.::::) g f a b c d e = f a b c d $ g e
+ src/Data/Functor/Composition.hs view
@@ -0,0 +1,26 @@+module Data.Functor.Composition where+++(<$$>) :: (Functor f0, Functor f1) =>+          (a -> b)+       -> f1 (f0 a)+       -> f1 (f0 b)+(<$$>) = fmap . fmap++(<$$$>) :: (Functor f0, Functor f1, Functor f2) =>+          (a -> b)+       -> f2 (f1 (f0 a))+       -> f2 (f1 (f0 b))+(<$$$>) = fmap . fmap . fmap++(<$$$$>) :: (Functor f0, Functor f1, Functor f2, Functor f3) =>+          (a -> b)+       -> f3 (f2 (f1 (f0 a)))+       -> f3 (f2 (f1 (f0 b)))+(<$$$$>) = fmap . fmap . fmap . fmap++(<$$$$$>) :: (Functor f0, Functor f1, Functor f2, Functor f3, Functor f4) =>+          (a -> b)+       -> f4 (f3 (f2 (f1 (f0 a))))+       -> f4 (f3 (f2 (f1 (f0 b))))+(<$$$$$>) = fmap . fmap . fmap . fmap . fmap
+ src/Data/Functor/Contravariant/Composition.hs view
@@ -0,0 +1,33 @@+module Data.Functor.Contravariant.Composition where++import Data.Functor.Contravariant++(<-$>) :: Contravariant f =>+          (a -> b)+       -> f b+       -> f a+(<-$>) = contramap++(<-$$>) :: (Contravariant f0, Contravariant f1) =>+          (a -> b)+       -> f1 (f0 a)+       -> f1 (f0 b)+(<-$$>) = contramap . contramap++(<-$$$>) :: (Contravariant f0, Contravariant f1, Contravariant f2) =>+          (a -> b)+       -> f2 (f1 (f0 b))+       -> f2 (f1 (f0 a))+(<-$$$>) = contramap . contramap . contramap++(<-$$$$>) :: (Contravariant f0, Contravariant f1, Contravariant f2, Contravariant f3) =>+          (a -> b)+       -> f3 (f2 (f1 (f0 a)))+       -> f3 (f2 (f1 (f0 b)))+(<-$$$$>) = contramap . contramap . contramap . contramap++(<-$$$$$>) :: (Contravariant f0, Contravariant f1, Contravariant f2, Contravariant f3, Contravariant f4) =>+          (a -> b)+       -> f4 (f3 (f2 (f1 (f0 b))))+       -> f4 (f3 (f2 (f1 (f0 a))))+(<-$$$$$>) = contramap . contramap . contramap . contramap . contramap