acme-cofunctor 0.1.0.0 → 0.1.1.0
raw patch · 4 files changed
+62/−3 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Cofunctor: instance Cofunctor ((,) a)
- Data.Cofunctor: instance Cofunctor ((->) a)
- Data.Cofunctor: instance Cofunctor (Either e)
- Data.Cofunctor: instance Cofunctor IO
- Data.Cofunctor: instance Cofunctor Maybe
- Data.Cofunctor: instance Cofunctor []
+ Data.Cofunctor: instance Data.Cofunctor.Cofunctor ((,) a)
+ Data.Cofunctor: instance Data.Cofunctor.Cofunctor ((->) a)
+ Data.Cofunctor: instance Data.Cofunctor.Cofunctor (Data.Either.Either e)
+ Data.Cofunctor: instance Data.Cofunctor.Cofunctor GHC.Base.Maybe
+ Data.Cofunctor: instance Data.Cofunctor.Cofunctor GHC.Types.IO
+ Data.Cofunctor: instance Data.Cofunctor.Cofunctor []
+ Data.Cofunctor.Cocoyoneda: [Cocoyoneda] :: (a -> b) -> f a -> Cocoyoneda f b
+ Data.Cofunctor.Cocoyoneda: data Cocoyoneda f a
+ Data.Cofunctor.Cocoyoneda: hoistCocoyoneda :: (forall a. f a -> g a) -> Cocoyoneda f b -> Cocoyoneda g b
+ Data.Cofunctor.Cocoyoneda: instance Data.Cofunctor.Cofunctor (Data.Cofunctor.Cocoyoneda.Cocoyoneda f)
+ Data.Cofunctor.Cocoyoneda: liftCocoyoneda :: f a -> Cocoyoneda f a
+ Data.Cofunctor.Cocoyoneda: lowerCocoyoneda :: Cofunctor f => Cocoyoneda f a -> f a
Files
- CHANGELOG.md +8/−0
- README.md +17/−0
- acme-cofunctor.cabal +10/−3
- src/Data/Cofunctor/Cocoyoneda.hs +27/−0
+ CHANGELOG.md view
@@ -0,0 +1,8 @@+CHANGELOG+=========++- 0.1.1.0 (2017-05-13)+ * Add `Data.Cofunctor.Cocoyoneda` module++- 0.1.0.0 (2014-11-28)+ * Initial release
+ README.md view
@@ -0,0 +1,17 @@+acme-cofunctor+==============++A `Cofunctor` is a structure from category theory dual to `Functor`.++We all know that a `Functor` is defined by the operation 'fmap':++ fmap :: (a -> b) -> (f a -> f b)++This means that its dual must be defined by the following operation:++ cofmap :: (b -> a) -> (f b -> f a)++Since beginning his investigations, the author of this package has discovered+that this pattern is _at least_ as commonly used as `Functor`. In fact, many+ubiquitous Haskell types (e.g. `[]`, `Maybe`, `((->) a)` turn out to have a+`Cofunctor` instance.
acme-cofunctor.cabal view
@@ -1,5 +1,5 @@ Name: acme-cofunctor-Version: 0.1.0.0+Version: 0.1.1.0 Synopsis: A Cofunctor is a structure from category theory dual to Functor License: BSD3 License-file: LICENSE@@ -37,11 +37,18 @@ ubiquitous Haskell types (e.g. @[]@, 'Maybe', @((->) a)@ turn out to have a 'Cofunctor' instance. +Extra-source-files:+ README.md+ CHANGELOG.md+ Library- Exposed-modules: Data.Cofunctor- default-language: Haskell98+ Default-language: Haskell98 Ghc-options: -Wall Hs-source-dirs: src++ Exposed-modules:+ Data.Cofunctor,+ Data.Cofunctor.Cocoyoneda Build-depends: base >= 4 && < 5
+ src/Data/Cofunctor/Cocoyoneda.hs view
@@ -0,0 +1,27 @@+{-# LANGUAGE GADTs #-}+{-# LANGUAGE RankNTypes #-}++-- | 'Cocoyoneda' gives a cofree cofunctor for any type constructor.+module Data.Cofunctor.Cocoyoneda+ ( Cocoyoneda(..)+ , liftCocoyoneda+ , lowerCocoyoneda+ , hoistCocoyoneda+ ) where++import Data.Cofunctor (Cofunctor(..))++data Cocoyoneda f a where+ Cocoyoneda :: (a -> b) -> f a -> Cocoyoneda f b++instance Cofunctor (Cocoyoneda f) where+ cofmap f (Cocoyoneda g x) = Cocoyoneda (f . g) x++liftCocoyoneda :: f a -> Cocoyoneda f a+liftCocoyoneda = Cocoyoneda id++lowerCocoyoneda :: Cofunctor f => Cocoyoneda f a -> f a+lowerCocoyoneda (Cocoyoneda f x) = cofmap f x++hoistCocoyoneda :: (forall a. f a -> g a) -> Cocoyoneda f b -> Cocoyoneda g b+hoistCocoyoneda f (Cocoyoneda g x) = Cocoyoneda g (f x)