comonad 0.6.1.2 → 0.6.2
raw patch · 2 files changed
+61/−2 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Distributive: class Functor g => Distributive g
+ Data.Distributive: cotraverse :: (Distributive g, Comonad w) => (w a -> b) -> w (g a) -> g b
+ Data.Distributive: distribute :: (Distributive g, Comonad w) => w (g a) -> g (w a)
+ Data.Distributive: fmapDefault :: Distributive g => (a -> b) -> g a -> g b
+ Data.Distributive: instance Distributive ((->) e)
+ Data.Distributive: instance Distributive Identity
+ Data.Distributive: instance Distributive g => Distributive (IdentityT g)
Files
- Data/Distributive.hs +59/−0
- comonad.cabal +2/−2
+ Data/Distributive.hs view
@@ -0,0 +1,59 @@+-----------------------------------------------------------------------------+-- |+-- Module : Data.Distributive+-- Copyright : (C) 2011 Edward Kmett+-- License : BSD-style (see the file LICENSE)+--+-- Maintainer : Edward Kmett <ekmett@gmail.com>+-- Stability : provisional+-- Portability : portable+--+----------------------------------------------------------------------------+module Data.Distributive + ( Distributive(..)+ , fmapDefault+ ) where++import Control.Applicative+import Control.Comonad+import Control.Monad.Trans.Identity+import Control.Monad.Instances ()+import Data.Functor.Identity++-- | This is the categorical dual of 'Traversable'+-- +-- Minimal definition: 'mapW' or 'distribute'+--+-- > mapW = fmap f . duplicate+-- > distribute = mapW id+-- +-- To be distributable a container will need to have a way to consistently+-- zip a potentially infinite number of copies of itself. This effectively+-- means that the holes in all values of that type, must have the same +-- cardinality, fixed sized vectors, infinite streams, functions, etc.+-- and no extra information to try to merge together.++class Functor g => Distributive g where+ -- | The dual of 'Data.Traversable.mapM'+ cotraverse :: Comonad w => (w a -> b) -> w (g a) -> g b++ -- | The dual of 'Data.Traversable.sequence'+ distribute :: Comonad w => w (g a) -> g (w a)++ cotraverse f = fmap f . distribute+ distribute = cotraverse id+ +instance Distributive Identity where+ cotraverse f = Identity . f . fmap runIdentity+ distribute = Identity . fmap runIdentity++instance Distributive ((->)e) where+ distribute w e = fmap ($e) w++instance Distributive g => Distributive (IdentityT g) where+ cotraverse f w = IdentityT $ cotraverse f (runIdentityT <$> w)+ distribute w = IdentityT $ distribute (runIdentityT <$> w)++-- | Every 'Distributive' is a 'Functor'. This is a valid default definition.+fmapDefault :: Distributive g => (a -> b) -> g a -> g b+fmapDefault f = cotraverse (f . runIdentity) . Identity
comonad.cabal view
@@ -1,6 +1,6 @@ name: comonad category: Control, Comonads-version: 0.6.1.2+version: 0.6.2 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -17,7 +17,6 @@ type: git location: git://github.com/ekmett/comonad.git - library build-depends: base >= 4 && < 4.4,@@ -25,5 +24,6 @@ exposed-modules: Control.Comonad+ Data.Distributive ghc-options: -Wall