category-extras 0.52.0 → 0.52.1
raw patch · 7 files changed
+83/−9 lines, 7 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Control.Functor.Limit: runColimit :: Colimit f -> f b
+ Control.Comonad.Stream: type Stream = Cofree Identity
+ Control.Functor.Cone: Cocone :: (forall a. f a -> n) -> Cocone f n
+ Control.Functor.Cone: instance Functor (Cocone f)
+ Control.Functor.Cone: instance Monad (Cocone f)
+ Control.Functor.Cone: instance MonadReader (Colimit f) (Cocone f)
+ Control.Functor.Cone: newtype Cocone f n
+ Control.Functor.Cone: runCocone :: Cocone f n -> forall a. f a -> n
+ Control.Functor.Cone: type Cone n f = n -> forall a. f a
+ Control.Functor.Extras: instance FunctorPlus Maybe
+ Control.Functor.Extras: instance FunctorPlus []
+ Control.Functor.Extras: instance FunctorZero Maybe
+ Control.Functor.Extras: instance FunctorZero []
- Control.Functor.Limit: Colimit :: f b -> Colimit f
+ Control.Functor.Limit: Colimit :: (f b) -> Colimit f
Files
- category-extras.cabal +5/−2
- src/Control/Comonad/Cofree.hs +4/−0
- src/Control/Comonad/Context.hs +0/−2
- src/Control/Comonad/Stream.hs +24/−0
- src/Control/Functor/Cone.hs +32/−0
- src/Control/Functor/Extras.hs +16/−3
- src/Control/Functor/Limit.hs +2/−2
category-extras.cabal view
@@ -1,6 +1,6 @@ name: category-extras category: Control, Monads, Comonads-version: 0.52.0+version: 0.52.1 license: BSD3 cabal-version: >= 1.2 license-file: LICENSE@@ -46,6 +46,7 @@ ExistentialQuantification, Rank2Types + exposed-modules: Control.Category.Monoidal, Control.Category.Cartesian,@@ -70,7 +71,8 @@ Control.Comonad.Parameterized, Control.Comonad.Pointer, Control.Comonad.Reader,- Control.Comonad.Supply+ Control.Comonad.Stream,+ Control.Comonad.Supply, Control.Comonad.Trans, Control.Functor, Control.Functor.Adjunction,@@ -78,6 +80,7 @@ Control.Functor.Algebra, Control.Functor.Algebra.Elgot, Control.Functor.Categorical,+ Control.Functor.Cone, Control.Functor.Composition, Control.Functor.Combinators.Const, Control.Functor.Combinators.Lift,
src/Control/Comonad/Cofree.hs view
@@ -9,6 +9,10 @@ -- Stability : experimental -- Portability : rank-2 types --+-- Examples: +-- type LV = Cofree Maybe+-- type Stream = Cofree Identity+ ---------------------------------------------------------------------------- module Control.Comonad.Cofree ( Cofree
src/Control/Comonad/Context.hs view
@@ -41,7 +41,6 @@ data Context s a = Context (s -> a) s - runContext :: (Context s s -> Context s b) -> s -> (b, s) runContext f s = (a b, b) where Context a b = f (Context id s)@@ -58,7 +57,6 @@ instance Comonad (Context s) where duplicate (Context f a) = Context (Context f) a- newtype ContextT s w a = ContextT { runContextT :: (w s -> a, w s) }
+ src/Control/Comonad/Stream.hs view
@@ -0,0 +1,24 @@+{-# OPTIONS_GHC -fglasgow-exts #-}+-----------------------------------------------------------------------------+-- |+-- Module : Control.Comonad.Stream+-- Copyright : (C) 2008 Edward Kmett+-- License : BSD-style (see the file LICENSE)+--+-- Maintainer : Edward Kmett <ekmett@gmail.com>+-- Stability : experimental+-- Portability : portable+--+----------------------------------------------------------------------------+module Control.Comonad.Stream+ ( Stream+ ) where+++import Control.Comonad.Cofree+import Control.Monad.Identity+type Stream = Cofree Identity++-- class ComonadStream w where fby :: a -> (w a -> a) +-- next :: w a -> w a +-- run :: (ComonadStream w, ComonadContext Int c) => (c a -> b) -> w a -> w b
+ src/Control/Functor/Cone.hs view
@@ -0,0 +1,32 @@+-----------------------------------------------------------------------------+-- |+-- Module : Control.Functor.Cone+-- Copyright : (C) 2008 Edward Kmett+-- License : BSD-style (see the file LICENSE)+--+-- Maintainer : Edward Kmett <ekmett@gmail.com>+-- Stability : experimental+-- Portability : non-portable (rank-2 polymorphism/existentials)+--+----------------------------------------------------------------------------+module Control.Functor.Cone+ ( Cone, Cocone(..)+ ) where++import Control.Monad.Reader+import Control.Functor.Limit++type Cone n f = n -> forall a. f a++newtype Cocone f n = Cocone { runCocone :: forall a. f a -> n }++instance Functor (Cocone f) where+ fmap f (Cocone g) = Cocone (f . g)++instance Monad (Cocone f) where+ return x = Cocone (\_ -> x)+ Cocone r >>= f = Cocone (\e -> runCocone (f (r e)) e)++instance MonadReader (Colimit f) (Cocone f) where+ ask = Cocone Colimit+ local f (Cocone r) = Cocone (\e -> case f (Colimit e) of Colimit e' -> r e')
src/Control/Functor/Extras.hs view
@@ -12,8 +12,10 @@ ---------------------------------------------------------------------------- module Control.Functor.Extras where -infixr 0 :~>, :~~> -- to match ->+import Control.Monad +infixr 0 :~>, :~~> -- to match ->'s fixity+ type Dist f g = forall a. f (g a) -> g (f a) -- A natural transformation between functors f and g.@@ -40,8 +42,6 @@ class Distributes f g where dist :: f (g a) -> g (f a) -- class Functor f => FunctorZero f where fzero :: f a @@ -51,3 +51,16 @@ class Functor f => FunctorSplit f where fsplit :: f a -> (f a, f a)++instance FunctorZero Maybe where+ fzero = Nothing++instance FunctorPlus Maybe where+ fplus = mplus++instance FunctorZero [] where+ fzero = []+ +instance FunctorPlus [] where+ fplus = (++)+
src/Control/Functor/Limit.hs view
@@ -6,7 +6,7 @@ -- -- Maintainer : Edward Kmett <ekmett@gmail.com> -- Stability : experimental--- Portability : non-portable (rank-2 polymorphism/existentials in Ran/Lan)+-- Portability : non-portable (rank-2 polymorphism/existentials) -- ---------------------------------------------------------------------------- module Control.Functor.Limit@@ -34,4 +34,4 @@ limit = (Left mempty) -- | @type Colimit = Lan (Const Void)@-data Colimit f = forall b. Colimit { runColimit :: f b }+data Colimit f = forall b. Colimit (f b)