free-category-0.0.1.0: Free category

Safe HaskellNone
LanguageHaskell2010

Control.Category.Free

Contents

Synopsis

Free category

data Cat :: (* -> * -> *) -> * -> * -> * where Source #

Free category encoded as a recursive data type, in a simlar way as Free. You can use FreeAlgebra2 class instance:

liftFree2    @Cat :: f a b -> Cat f ab
foldNatFree2 @Cat :: Category d => (forall x y. f x y -> d x y) -> Cat f a b -> d a b

The same performance concerns that apply to Free apply to this encoding of a free category.

Constructors

Id :: Cat f a a 
(:.:) :: f b c -> Cat f a b -> Cat f a c infixr 9 
Instances
FreeAlgebra2 Cat Source # 
Instance details

Defined in Control.Category.Free

Methods

liftFree2 :: AlgebraType0 Cat f => f a b -> Cat f a b #

foldNatFree2 :: (AlgebraType Cat d, AlgebraType0 Cat f) => (forall x y. f x y -> d x y) -> Cat f a b -> d a b #

codom2 :: AlgebraType0 Cat f => Proof (AlgebraType Cat (Cat f)) (Cat f) #

forget2 :: AlgebraType Cat f => Proof (AlgebraType0 Cat f) (Cat f) #

Arrow f => Arrow (Cat f) Source # 
Instance details

Defined in Control.Category.Free

Methods

arr :: (b -> c) -> Cat f b c #

first :: Cat f b c -> Cat f (b, d) (c, d) #

second :: Cat f b c -> Cat f (d, b) (d, c) #

(***) :: Cat f b c -> Cat f b' c' -> Cat f (b, b') (c, c') #

(&&&) :: Cat f b c -> Cat f b c' -> Cat f b (c, c') #

ArrowZero f => ArrowZero (Cat f) Source # 
Instance details

Defined in Control.Category.Free

Methods

zeroArrow :: Cat f b c #

ArrowChoice f => ArrowChoice (Cat f) Source # 
Instance details

Defined in Control.Category.Free

Methods

left :: Cat f b c -> Cat f (Either b d) (Either c d) #

right :: Cat f b c -> Cat f (Either d b) (Either d c) #

(+++) :: Cat f b c -> Cat f b' c' -> Cat f (Either b b') (Either c c') #

(|||) :: Cat f b d -> Cat f c d -> Cat f (Either b c) d #

Category (Cat f :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

id :: Cat f a a #

(.) :: Cat f b c -> Cat f a b -> Cat f a c #

Semigroup (Cat f o o) Source # 
Instance details

Defined in Control.Category.Free

Methods

(<>) :: Cat f o o -> Cat f o o -> Cat f o o #

sconcat :: NonEmpty (Cat f o o) -> Cat f o o #

stimes :: Integral b => b -> Cat f o o -> Cat f o o #

Monoid (Cat f o o) Source # 
Instance details

Defined in Control.Category.Free

Methods

mempty :: Cat f o o #

mappend :: Cat f o o -> Cat f o o -> Cat f o o #

mconcat :: [Cat f o o] -> Cat f o o #

MSet (Cat f o o) (Cat f a o) Source # 
Instance details

Defined in Control.Category.Free

Methods

mact :: Cat f o o -> Cat f a o -> Cat f a o #

SSet (Cat f o o) (Cat f a o) Source # 
Instance details

Defined in Control.Category.Free

Methods

act :: Cat f o o -> Cat f a o -> Cat f a o #

type AlgebraType0 Cat (f :: l) Source # 
Instance details

Defined in Control.Category.Free

type AlgebraType0 Cat (f :: l) = ()
type AlgebraType Cat (c :: k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

type AlgebraType Cat (c :: k -> k -> Type) = Category c

Free category (CPS style)

newtype C f a b Source #

CPS style encoded free category; one can use FreeAlgebra2 class instance:

liftFree2    @C :: f a b -> C f ab
foldNatFree2 @C :: Category d => (forall x y. f x y -> d x y) -> C f a b -> d a b

Constructors

C 

Fields

  • runC :: forall r. Category r => (forall x y. f x y -> r x y) -> r a b
     
Instances
Category (C f :: k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

id :: C f a a #

(.) :: C f b c -> C f a b -> C f a c #

FreeAlgebra2 (C :: (Type -> Type -> Type) -> Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

liftFree2 :: AlgebraType0 C f => f a b -> C f a b #

foldNatFree2 :: (AlgebraType C d, AlgebraType0 C f) => (forall x y. f x y -> d x y) -> C f a b -> d a b #

codom2 :: AlgebraType0 C f => Proof (AlgebraType C (C f)) (C f) #

forget2 :: AlgebraType C f => Proof (AlgebraType0 C f) (C f) #

Arrow f => Arrow (C f) Source # 
Instance details

Defined in Control.Category.Free

Methods

arr :: (b -> c) -> C f b c #

first :: C f b c -> C f (b, d) (c, d) #

second :: C f b c -> C f (d, b) (d, c) #

(***) :: C f b c -> C f b' c' -> C f (b, b') (c, c') #

(&&&) :: C f b c -> C f b c' -> C f b (c, c') #

ArrowZero f => ArrowZero (C f) Source # 
Instance details

Defined in Control.Category.Free

Methods

zeroArrow :: C f b c #

ArrowChoice f => ArrowChoice (C f) Source # 
Instance details

Defined in Control.Category.Free

Methods

left :: C f b c -> C f (Either b d) (Either c d) #

right :: C f b c -> C f (Either d b) (Either d c) #

(+++) :: C f b c -> C f b' c' -> C f (Either b b') (Either c c') #

(|||) :: C f b d -> C f c d -> C f (Either b c) d #

Semigroup (C f o o) Source # 
Instance details

Defined in Control.Category.Free

Methods

(<>) :: C f o o -> C f o o -> C f o o #

sconcat :: NonEmpty (C f o o) -> C f o o #

stimes :: Integral b => b -> C f o o -> C f o o #

Monoid (C f o o) Source # 
Instance details

Defined in Control.Category.Free

Methods

mempty :: C f o o #

mappend :: C f o o -> C f o o -> C f o o #

mconcat :: [C f o o] -> C f o o #

MSet (C f o o) (C f a o) Source # 
Instance details

Defined in Control.Category.Free

Methods

mact :: C f o o -> C f a o -> C f a o #

SSet (C f o o) (C f a o) Source # 
Instance details

Defined in Control.Category.Free

Methods

act :: C f o o -> C f a o -> C f a o #

type AlgebraType0 (C :: (k -> k -> Type) -> k -> k -> Type) (f :: l) Source # 
Instance details

Defined in Control.Category.Free

type AlgebraType0 (C :: (k -> k -> Type) -> k -> k -> Type) (f :: l) = ()
type AlgebraType (C :: (k2 -> k2 -> Type) -> k2 -> k2 -> Type) (c :: k1 -> k1 -> Type) Source # 
Instance details

Defined in Control.Category.Free

type AlgebraType (C :: (k2 -> k2 -> Type) -> k2 -> k2 -> Type) (c :: k1 -> k1 -> Type) = Category c

toC :: Cat f a b -> C f a b Source #

Isomorphism from Cat to C, which is a specialisation of hoistFreeH2.

fromC :: C f a b -> Cat f a b Source #

Inverse of fromC, which also is a specialisatin of hoistFreeH2.

Free interface re-exports

class FreeAlgebra2 (m :: (Type -> Type -> Type) -> Type -> Type -> Type) where #

Free algebra similar to FreeAlgebra1 and FreeAlgebra, but for types of kind Type -> Type -> Type. Examples include free categories, free arrows, etc (see 'free-category' package).

Methods

liftFree2 :: AlgebraType0 m f => f a b -> m f a b #

foldNatFree2 :: (AlgebraType m d, AlgebraType0 m f) => (forall x y. f x y -> d x y) -> m f a b -> d a b #

codom2 :: AlgebraType0 m f => Proof (AlgebraType m (m f)) (m f) #

forget2 :: AlgebraType m f => Proof (AlgebraType0 m f) (m f) #

Instances
FreeAlgebra2 A Source # 
Instance details

Defined in Control.Arrow.Free

Methods

liftFree2 :: AlgebraType0 A f => f a b -> A f a b #

foldNatFree2 :: (AlgebraType A d, AlgebraType0 A f) => (forall x y. f x y -> d x y) -> A f a b -> d a b #

codom2 :: AlgebraType0 A f => Proof (AlgebraType A (A f)) (A f) #

forget2 :: AlgebraType A f => Proof (AlgebraType0 A f) (A f) #

FreeAlgebra2 Arr Source # 
Instance details

Defined in Control.Arrow.Free

Methods

liftFree2 :: AlgebraType0 Arr f => f a b -> Arr f a b #

foldNatFree2 :: (AlgebraType Arr d, AlgebraType0 Arr f) => (forall x y. f x y -> d x y) -> Arr f a b -> d a b #

codom2 :: AlgebraType0 Arr f => Proof (AlgebraType Arr (Arr f)) (Arr f) #

forget2 :: AlgebraType Arr f => Proof (AlgebraType0 Arr f) (Arr f) #

FreeAlgebra2 Cat Source # 
Instance details

Defined in Control.Category.Free

Methods

liftFree2 :: AlgebraType0 Cat f => f a b -> Cat f a b #

foldNatFree2 :: (AlgebraType Cat d, AlgebraType0 Cat f) => (forall x y. f x y -> d x y) -> Cat f a b -> d a b #

codom2 :: AlgebraType0 Cat f => Proof (AlgebraType Cat (Cat f)) (Cat f) #

forget2 :: AlgebraType Cat f => Proof (AlgebraType0 Cat f) (Cat f) #

FreeAlgebra2 (C :: (Type -> Type -> Type) -> Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

liftFree2 :: AlgebraType0 C f => f a b -> C f a b #

foldNatFree2 :: (AlgebraType C d, AlgebraType0 C f) => (forall x y. f x y -> d x y) -> C f a b -> d a b #

codom2 :: AlgebraType0 C f => Proof (AlgebraType C (C f)) (C f) #

forget2 :: AlgebraType C f => Proof (AlgebraType0 C f) (C f) #

wrapFree2 :: (AlgebraType0 m f, FreeAlgebra2 m, Monad (m f a)) => f a (m f a b) -> m f a b #

foldFree2 :: (FreeAlgebra2 m, AlgebraType m f) => m f a b -> f a b #

hoistFree2 :: (FreeAlgebra2 m, AlgebraType0 m g, AlgebraType0 m f) => (forall x y. f x y -> g x y) -> m f a b -> m g a b #

joinFree2 :: (FreeAlgebra2 m, AlgebraType0 m f) => m (m f) a b -> m f a b #

bindFree2 :: (FreeAlgebra2 m, AlgebraType0 m g, AlgebraType0 m f) => m f a b -> (forall x y. f x y -> m g x y) -> m g a b #