packages feed

semigroupoids 1.1.0 → 1.1.1

raw patch · 4 files changed

+53/−5 lines, 4 files

Files

Data/Semigroup/Foldable.hs view
@@ -17,11 +17,16 @@   , foldMapDefault1   ) where -import Prelude hiding (foldr)+import Control.Monad.Trans.Identity import Data.Foldable+import Data.Functor.Identity import Data.Functor.Apply-import Data.Semigroup-import Data.Monoid+import Data.Functor.Product+import Data.Functor.Compose+import Data.Semigroup hiding (Product)+import Data.Monoid hiding (Product)+import Data.Traversable.Instances ()+import Prelude hiding (foldr)  class Foldable t => Foldable1 t where   fold1 :: Semigroup m => t m -> m@@ -29,6 +34,18 @@    foldMap1 f = maybe (error "foldMap1") id . getOption . foldMap (Option . Just . f)    fold1 = foldMap1 id++instance Foldable1 Identity where+  foldMap1 f = f . runIdentity++instance Foldable1 m => Foldable1 (IdentityT m) where+  foldMap1 f = foldMap1 f . runIdentityT++instance (Foldable1 f, Foldable1 g) => Foldable1 (Compose f g) where+  foldMap1 f = foldMap1 (foldMap1 f) . getCompose++instance (Foldable1 f, Foldable1 g) => Foldable1 (Product f g) where+  foldMap1 f (Pair a b) = foldMap1 f a <> foldMap1 f b  newtype Act f a = Act { getAct :: f a } 
Data/Semigroup/Traversable.hs view
@@ -15,10 +15,15 @@   ) where  import Control.Applicative+import Control.Monad.Trans.Identity+import Data.Functor.Identity import Data.Functor.Apply+import Data.Functor.Product+import Data.Functor.Compose import Data.Semigroup.Foldable import Data.Traversable-import Data.Semigroup+import Data.Semigroup hiding (Product)+import Data.Traversable.Instances ()  class (Foldable1 t, Traversable t) => Traversable1 t where   traverse1 :: Apply f => (a -> f b) -> t a -> f (t b)@@ -29,3 +34,15 @@  foldMap1Default :: (Traversable1 f, Semigroup m) => (a -> m) -> f a -> m foldMap1Default f = getConst . traverse1 (Const . f)++instance Traversable1 Identity where+  traverse1 f = fmap Identity . f . runIdentity++instance Traversable1 f => Traversable1 (IdentityT f) where+  traverse1 f = fmap IdentityT . traverse1 f . runIdentityT++instance (Traversable1 f, Traversable1 g) => Traversable1 (Compose f g) where+  traverse1 f = fmap Compose . traverse1 (traverse1 f) . getCompose++instance (Traversable1 f, Traversable1 g) => Traversable1 (Product f g) where+  traverse1 f (Pair a b) = Pair <$> traverse1 f a <.> traverse1 f b
+ Data/Traversable/Instances.hs view
@@ -0,0 +1,13 @@+-- | Placeholders for missing instances of Traversable, until base catches up and adds them+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Data.Traversable.Instances where++import Control.Monad.Trans.Identity+import Data.Foldable+import Data.Traversable++instance Foldable m => Foldable (IdentityT m) where+  foldMap f = foldMap f . runIdentityT++instance Traversable m => Traversable (IdentityT m) where+  traverse f = fmap IdentityT . traverse f . runIdentityT
semigroupoids.cabal view
@@ -1,6 +1,6 @@ name:          semigroupoids category:      Control, Comonads-version:       1.1.0+version:       1.1.1 license:       BSD3 cabal-version: >= 1.6 license-file:  LICENSE@@ -80,5 +80,6 @@     Data.Semigroupoid     Data.Semigroupoid.Dual     Data.Semigroupoid.Static+    Data.Traversable.Instances    ghc-options: -Wall