comonad-transformers 0.10.0 → 0.10.1
raw patch · 3 files changed
+55/−66 lines, 3 filesdep ~syb-extrasPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: syb-extras
API changes (from Hackage documentation)
- Data.Functor.Extend.Trans.Maybe: MaybeT :: Maybe (w a) -> MaybeT w a
- Data.Functor.Extend.Trans.Maybe: data MaybeT w a
- Data.Functor.Extend.Trans.Maybe: instance Applicative w => Alternative (MaybeT w)
- Data.Functor.Extend.Trans.Maybe: instance Applicative w => Applicative (MaybeT w)
- Data.Functor.Extend.Trans.Maybe: instance Apply w => Alt (MaybeT w)
- Data.Functor.Extend.Trans.Maybe: instance Apply w => Apply (MaybeT w)
- Data.Functor.Extend.Trans.Maybe: instance Extend w => Extend (MaybeT w)
- Data.Functor.Extend.Trans.Maybe: instance Functor w => Functor (MaybeT w)
- Data.Functor.Extend.Trans.Maybe: justT :: w a -> MaybeT w a
- Data.Functor.Extend.Trans.Maybe: maybeT :: a -> (w b -> a) -> MaybeT w b -> a
- Data.Functor.Extend.Trans.Maybe: nothing :: MaybeT w a
- Data.Functor.Extend.Trans.Maybe: runMaybeT :: MaybeT w a -> Maybe (w a)
+ Data.Functor.Coproduct: Coproduct :: Either (f a) (g a) -> Coproduct f g a
+ Data.Functor.Coproduct: coproduct :: (f a -> b) -> (g a -> b) -> Coproduct f g a -> b
+ Data.Functor.Coproduct: getCoproduct :: Coproduct f g a -> Either (f a) (g a)
+ Data.Functor.Coproduct: instance (Comonad f, Comonad g) => Comonad (Coproduct f g)
+ Data.Functor.Coproduct: instance (Extend f, Extend g) => Extend (Coproduct f g)
+ Data.Functor.Coproduct: instance (Foldable f, Foldable g) => Foldable (Coproduct f g)
+ Data.Functor.Coproduct: instance (Functor f, Functor g) => Functor (Coproduct f g)
+ Data.Functor.Coproduct: instance (Traversable f, Traversable g) => Traversable (Coproduct f g)
+ Data.Functor.Coproduct: left :: f a -> Coproduct f g a
+ Data.Functor.Coproduct: newtype Coproduct f g a
+ Data.Functor.Coproduct: right :: g a -> Coproduct f g a
Files
- Data/Functor/Coproduct.hs +53/−0
- Data/Functor/Extend/Trans/Maybe.hs +0/−62
- comonad-transformers.cabal +2/−4
+ Data/Functor/Coproduct.hs view
@@ -0,0 +1,53 @@+-----------------------------------------------------------------------------+-- |+-- Module : Data.Functor.Coproduct+-- Copyright : (C) 2008-2011 Edward Kmett+-- License : BSD-style (see the file LICENSE)+--+-- Maintainer : Edward Kmett <ekmett@gmail.com>+-- Stability : provisional+-- Portability : portable+----------------------------------------------------------------------------+module Data.Functor.Coproduct+ ( Coproduct(..) + , left+ , right+ , coproduct+ ) where++import Control.Comonad+import Data.Functor.Apply+import Data.Functor.Alt+import Data.Functor.Extend+import Data.Foldable+import Data.Traversable++newtype Coproduct f g a = Coproduct { getCoproduct :: Either (f a) (g a) }++left :: f a -> Coproduct f g a+left = Coproduct . Left++right :: g a -> Coproduct f g a+right = Coproduct . Right++coproduct :: (f a -> b) -> (g a -> b) -> Coproduct f g a -> b+coproduct f g = either f g . getCoproduct++instance (Functor f, Functor g) => Functor (Coproduct f g) where+ fmap f = Coproduct . coproduct (Left . fmap f) (Right . fmap f)++instance (Foldable f, Foldable g) => Foldable (Coproduct f g) where+ foldMap f = coproduct (foldMap f) (foldMap f)++instance (Traversable f, Traversable g) => Traversable (Coproduct f g) where+ traverse f = coproduct+ (fmap (Coproduct . Left) . traverse f) + (fmap (Coproduct . Right) . traverse f)+ +instance (Extend f, Extend g) => Extend (Coproduct f g) where+ extend f = Coproduct . coproduct+ (Left . extend (f . Coproduct . Left))+ (Right . extend (f . Coproduct . Right))++instance (Comonad f, Comonad g) => Comonad (Coproduct f g) where+ extract = coproduct extract extract
− Data/Functor/Extend/Trans/Maybe.hs
@@ -1,62 +0,0 @@--------------------------------------------------------------------------------- |--- Module : Data.Functor.Extend.Trans.Maybe--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------------------------------------------------------------------------------module Data.Functor.Extend.Trans.Maybe- ( MaybeT(..), maybeT, nothing, justT ) where--import Control.Applicative-import Data.Functor.Apply-import Data.Functor.Alt-import Data.Functor.Extend--- import Data.Functor.Extend.Trans.Class--{--type Maybe = MaybeT Identity-maybe :: a -> (b -> a) -> Maybe a b-just :: a -> Maybe a--}--data MaybeT w a = MaybeT { runMaybeT :: Maybe (w a) }--instance Functor w => Functor (MaybeT w) where- fmap f = MaybeT . fmap (fmap f) . runMaybeT--instance Extend w => Extend (MaybeT w) where- duplicate (MaybeT (Just w)) = MaybeT $ Just $ extend (MaybeT . Just) w- duplicate (MaybeT Nothing) = MaybeT Nothing--{--instance ExtendHoist MaybeT where- cohoistE (MaybeT m) = MaybeT $ fmap (Identity . extract) m--}- -maybeT :: a -> (w b -> a) -> MaybeT w b -> a-maybeT z f = maybe z f . runMaybeT --nothing :: MaybeT w a -nothing = MaybeT Nothing--justT :: w a -> MaybeT w a -justT = MaybeT . Just--instance Apply w => Apply (MaybeT w) where- MaybeT a <.> MaybeT b = MaybeT $ (<.>) <$> a <.> b--instance Applicative w => Applicative (MaybeT w) where- pure = MaybeT . Just . pure- MaybeT a <*> MaybeT b = MaybeT $ (<*>) <$> a <*> b---- TODO: weaken Alt-instance Apply w => Alt (MaybeT w) where- MaybeT a <!> MaybeT b = MaybeT $ a <!> b--instance Applicative w => Alternative (MaybeT w) where- empty = MaybeT Nothing- MaybeT a <|> MaybeT b = MaybeT $ a <|> b
comonad-transformers.cabal view
@@ -1,6 +1,6 @@ name: comonad-transformers category: Control, Comonads-version: 0.10.0+version: 0.10.1 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -27,7 +27,6 @@ functor-apply >= 0.10.0 && < 0.11, semigroups >= 0.3.4 && < 0.4, prelude-extras >= 0.1 && < 0.3,- syb-extras >= 0.1 && < 0.3, transformers >= 0.2.0 && <= 0.3 if impl(ghc)@@ -51,8 +50,7 @@ Control.Comonad.Trans.Store.Strict Control.Comonad.Trans.Traced Control.Comonad.Trans.Stream+ Data.Functor.Coproduct Data.Functor.Extend.Trans.Class- Data.Functor.Extend.Trans.Maybe ghc-options: -Wall -