semigroupoids 1.2.1 → 1.2.2
raw patch · 4 files changed
+9/−191 lines, 4 filesdep −bifunctors
Dependencies removed: bifunctors
Files
- Data/Bifunctor/Apply.hs +0/−62
- Data/Semigroup/Bifoldable.hs +0/−68
- Data/Semigroup/Bitraversable.hs +0/−39
- semigroupoids.cabal +9/−22
− Data/Bifunctor/Apply.hs
@@ -1,62 +0,0 @@--------------------------------------------------------------------------------- |--- Module : Data.Bifunctor.Apply--- Copyright : (C) 2011 Edward Kmett,--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable---------------------------------------------------------------------------------module Data.Bifunctor.Apply ( - -- * Functors- -- * Applyable bifunctors- Biapply(..)- , (<<$>>)- , (<<..>>)- , bilift2- , bilift3- , module Data.Bifunctor- ) where---- import _everything_-import Data.Bifunctor--infixl 4 <<$>>, <<.>>, <<., .>>, <<..>>--(<<$>>) :: (a -> b) -> a -> b-(<<$>>) = id---- | A strong lax semi-monoidal endofunctor. --- This is equivalent to an 'Applicative' without 'pure'.--- --- Laws: ------ > associative composition: (.) <$> u <.> v <.> w = u <.> (v <.> w)-class Bifunctor p => Biapply p where- (<<.>>) :: p (a -> b) (c -> d) -> p a c -> p b d-- -- | a .> b = const id <$> a <.> b- (.>>) :: p a b -> p c d -> p c d- a .>> b = bimap (const id) (const id) <<$>> a <<.>> b-- -- | a <. b = const <$> a <.> b- (<<.) :: p a b -> p c d -> p a b- a <<. b = bimap const const <<$>> a <<.>> b--(<<..>>) :: Biapply p => p a c -> p (a -> b) (c -> d) -> p b d-(<<..>>) = bilift2 (flip id) (flip id) ---- | Lift a binary function into a comonad with zipping-bilift2 :: Biapply w => (a -> b -> c) -> (d -> e -> f) -> w a d -> w b e -> w c f-bilift2 f g a b = bimap f g <<$>> a <<.>> b-{-# INLINE bilift2 #-}---- | Lift a ternary function into a comonad with zipping-bilift3 :: Biapply w => (a -> b -> c -> d) -> (e -> f -> g -> h) -> w a e -> w b f -> w c g -> w d h-bilift3 f g a b c = bimap f g <<$>> a <<.>> b <<.>> c-{-# INLINE bilift3 #-}--instance Biapply (,) where- (f, g) <<.>> (a, b) = (f a, g b)
− Data/Semigroup/Bifoldable.hs
@@ -1,68 +0,0 @@--------------------------------------------------------------------------------- |--- Module : Data.Semigroup.Foldable--- Copyright : (C) 2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable---------------------------------------------------------------------------------module Data.Semigroup.Bifoldable- ( Bifoldable1(..)- , bitraverse1_- , bifor1_- , bisequenceA1_- , bifoldMapDefault1- ) where--import Prelude hiding (foldr)-import Data.Bifoldable-import Data.Functor.Apply-import Data.Semigroup-import Data.Monoid--class Bifoldable t => Bifoldable1 t where- bifold1 :: Semigroup m => t m m -> m- bifold1 = bifoldMap1 id id-- bifoldMap1 :: Semigroup m => (a -> m) -> (b -> m) -> t a b -> m- bifoldMap1 f g = maybe (error "bifoldMap1") id . getOption . bifoldMap (Option . Just . f) (Option . Just . g)--instance Bifoldable1 Either where- bifoldMap1 f _ (Left a) = f a- bifoldMap1 _ g (Right b) = g b--instance Bifoldable1 (,) where- bifoldMap1 f g (a, b) = f a <> g b--newtype Act f a = Act { getAct :: f a }--instance Apply f => Semigroup (Act f a) where- Act a <> Act b = Act (a .> b)--instance Functor f => Functor (Act f) where- fmap f (Act a) = Act (f <$> a)- b <$ Act a = Act (b <$ a)--bitraverse1_ :: (Bifoldable1 t, Apply f) => (a -> f b) -> (c -> f d) -> t a c -> f ()-bitraverse1_ f g t = getAct (bifoldMap1 (Act . ignore . f) (Act . ignore . g) t)-{-# INLINE bitraverse1_ #-}--bifor1_ :: (Bifoldable1 t, Apply f) => t a c -> (a -> f b) -> (c -> f d) -> f ()-bifor1_ t f g = bitraverse1_ f g t -{-# INLINE bifor1_ #-}--ignore :: Functor f => f a -> f ()-ignore = (() <$)--bisequenceA1_ :: (Bifoldable1 t, Apply f) => t (f a) (f b) -> f ()-bisequenceA1_ t = getAct (bifoldMap1 (Act . ignore) (Act . ignore) t)-{-# INLINE bisequenceA1_ #-}---- | Usable default for foldMap, but only if you define bifoldMap1 yourself-bifoldMapDefault1 :: (Bifoldable1 t, Monoid m) => (a -> m) -> (b -> m) -> t a b -> m-bifoldMapDefault1 f g = unwrapMonoid . bifoldMap (WrapMonoid . f) (WrapMonoid . g)-{-# INLINE bifoldMapDefault1 #-}-
− Data/Semigroup/Bitraversable.hs
@@ -1,39 +0,0 @@--------------------------------------------------------------------------------- |--- Module : Data.Semigroup.Bitraversable--- Copyright : (C) 2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable---------------------------------------------------------------------------------module Data.Semigroup.Bitraversable- ( Bitraversable1(..)- , bifoldMap1Default- ) where--import Control.Applicative-import Data.Functor.Apply-import Data.Semigroup.Bifoldable-import Data.Bitraversable-import Data.Bifunctor-import Data.Semigroup--class (Bifoldable1 t, Bitraversable t) => Bitraversable1 t where- bitraverse1 :: Apply f => (a -> f b) -> (c -> f d) -> t a c -> f (t b d)- bitraverse1 f g = bisequence1 . bimap f g-- bisequence1 :: Apply f => t (f a) (f b) -> f (t a b)- bisequence1 = bitraverse1 id id--bifoldMap1Default :: (Bitraversable1 t, Semigroup m) => (a -> m) -> (b -> m) -> t a b -> m-bifoldMap1Default f g = getConst . bitraverse1 (Const . f) (Const . g)--instance Bitraversable1 Either where- bitraverse1 f _ (Left a) = Left <$> f a- bitraverse1 _ g (Right b) = Right <$> g b--instance Bitraversable1 (,) where- bitraverse1 f g (a, b) = (,) <$> f a <.> g b
semigroupoids.cabal view
@@ -1,6 +1,6 @@ name: semigroupoids category: Control, Comonads-version: 1.2.1+version: 1.2.2 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -25,23 +25,14 @@ . Ideally the following relationships would hold: .- > Traversable <---- Foldable <--- Functor ------> Alt ---------> Plus - > | | | | - > v v v v - > Traversable1 <--- Foldable1 Apply --------> Applicative -> Alternative- > | | | - > v v v - > Bind ---------> Monad -------> MonadPlus + > Traversable <---- Foldable <--- Functor ------> Alt ---------> Plus Semigroupoid+ > | | | | |+ > v v v v v+ > Traversable1 <--- Foldable1 Apply --------> Applicative -> Alternative Category+ > | | | |+ > v v v v+ > Bind ---------> Monad -------> MonadPlus Arrow > - > - >- > Bitraversable <-- Bifoldable <- Bifunctor Semigroupoid- > | | | |- > v v v v- > Bitraversable1 <- Bifoldable1 Biapply Category- > |- > v- > Arrow . Apply, Bind, and Extract give rise the Static, Kleisli and Cokleisli semigroupoids respectively. .@@ -63,18 +54,14 @@ containers >= 0.3 && < 0.5, contravariant >= 0.1.2 && < 0.2, comonad >= 1.1 && < 1.2, - semigroups >= 0.5 && < 0.6,- bifunctors >= 0.1 && < 0.2+ semigroups >= 0.5 && < 0.6 exposed-modules:- Data.Bifunctor.Apply, Data.Functor.Alt, Data.Functor.Apply, Data.Functor.Bind, Data.Functor.Bind.Trans, Data.Functor.Plus,- Data.Semigroup.Bifoldable,- Data.Semigroup.Bitraversable Data.Semigroup.Foldable, Data.Semigroup.Traversable Data.Semigroupoid