rings-0.1.2: Ring-like objects.

Safe HaskellSafe
LanguageHaskell2010

Data.Semimodule.Algebra

Contents

Synopsis

Algebras

type FreeAlgebra a f = (FreeSemimodule a f, Algebra a (Rep f)) Source #

An algebra over a free module f.

Note that this is distinct from a free algebra.

class Semiring a => Algebra a b where Source #

An algebra algebra over a semiring.

Note that the algebra needn't be associative.

Minimal complete definition

Nothing

Methods

joined :: (b -> b -> a) -> b -> a Source #

diagonal :: Tran a b (b, b) Source #

rmap' (((c1,()),(c2,())) -> (c1,c2)) $ (id *** initial) . diagonal = id
rmap' ((((),c1),((),c2)) -> (c1,c2)) $ (initial *** id) . diagonal = id
Instances
Semiring a => Algebra a IntSet Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

joined :: (IntSet -> IntSet -> a) -> IntSet -> a Source #

diagonal :: Tran a IntSet (IntSet, IntSet) Source #

Semiring a => Algebra a () Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

joined :: (() -> () -> a) -> () -> a Source #

diagonal :: Tran a () ((), ()) Source #

Semiring r => Algebra r E4 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

joined :: (E4 -> E4 -> r) -> E4 -> r Source #

diagonal :: Tran r E4 (E4, E4) Source #

Semiring r => Algebra r E3 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

joined :: (E3 -> E3 -> r) -> E3 -> r Source #

diagonal :: Tran r E3 (E3, E3) Source #

Semiring r => Algebra r E2 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

joined :: (E2 -> E2 -> r) -> E2 -> r Source #

diagonal :: Tran r E2 (E2, E2) Source #

Semiring r => Algebra r E1 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

joined :: (E1 -> E1 -> r) -> E1 -> r Source #

diagonal :: Tran r E1 (E1, E1) Source #

(Semiring a, Ord b) => Algebra a (Set b) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

joined :: (Set b -> Set b -> a) -> Set b -> a Source #

diagonal :: Tran a (Set b) (Set b, Set b) Source #

Semiring a => Algebra a (Seq b) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

joined :: (Seq b -> Seq b -> a) -> Seq b -> a Source #

diagonal :: Tran a (Seq b) (Seq b, Seq b) Source #

Semiring a => Algebra a [b] Source #

Tensor algebra on b.

>>> joined (<>) [1..3 :: Int]
[1,2,3,1,2,3,1,2,3,1,2,3]
>>> joined (\f g -> fold (f ++ g)) [1..3] :: Int
24
Instance details

Defined in Data.Semimodule.Algebra

Methods

joined :: ([b] -> [b] -> a) -> [b] -> a Source #

diagonal :: Tran a [b] ([b], [b]) Source #

(Algebra a b1, Algebra a b2) => Algebra a (b1, b2) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

joined :: ((b1, b2) -> (b1, b2) -> a) -> (b1, b2) -> a Source #

diagonal :: Tran a (b1, b2) ((b1, b2), (b1, b2)) Source #

(Algebra a b1, Algebra a b2, Algebra a b3) => Algebra a (b1, b2, b3) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

joined :: ((b1, b2, b3) -> (b1, b2, b3) -> a) -> (b1, b2, b3) -> a Source #

diagonal :: Tran a (b1, b2, b3) ((b1, b2, b3), (b1, b2, b3)) Source #

diag :: FreeAlgebra a f => (f ** f) a -> f a Source #

Obtain the diagonal of a tensor product as a vector.

When the coalgebra is trivial we have:

 diag f = tabulate $ joined (index . index (getCompose f))
>>> diag $ m22 1.0 2.0 3.0 4.0
V2 1.0 4.0

(.*.) :: FreeAlgebra a f => f a -> f a -> f a infixl 7 Source #

Multiplication operator on an algebra over a free semimodule.

Caution in general (.*.) needn't be commutative, nor associative.

Unital Algebras

type FreeUnital a f = (FreeAlgebra a f, Unital a (Rep f)) Source #

A unital algebra over a free semimodule f.

class Algebra a b => Unital a b where Source #

A unital algebra over a semiring.

Minimal complete definition

Nothing

Methods

unital :: a -> b -> a Source #

initial :: Tran a b () Source #

Instances
Semiring a => Unital a IntSet Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

unital :: a -> IntSet -> a Source #

initial :: Tran a IntSet () Source #

Semiring a => Unital a () Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

unital :: a -> () -> a Source #

initial :: Tran a () () Source #

Semiring r => Unital r E4 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

unital :: r -> E4 -> r Source #

initial :: Tran r E4 () Source #

Semiring r => Unital r E3 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

unital :: r -> E3 -> r Source #

initial :: Tran r E3 () Source #

Semiring r => Unital r E2 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

unital :: r -> E2 -> r Source #

initial :: Tran r E2 () Source #

Semiring r => Unital r E1 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

unital :: r -> E1 -> r Source #

initial :: Tran r E1 () Source #

(Semiring a, Ord b) => Unital a (Set b) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

unital :: a -> Set b -> a Source #

initial :: Tran a (Set b) () Source #

Semiring a => Unital a (Seq b) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

unital :: a -> Seq b -> a Source #

initial :: Tran a (Seq b) () Source #

Semiring a => Unital a [b] Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

unital :: a -> [b] -> a Source #

initial :: Tran a [b] () Source #

(Unital a b1, Unital a b2) => Unital a (b1, b2) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

unital :: a -> (b1, b2) -> a Source #

initial :: Tran a (b1, b2) () Source #

(Unital a b1, Unital a b2, Unital a b3) => Unital a (b1, b2, b3) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

unital :: a -> (b1, b2, b3) -> a Source #

initial :: Tran a (b1, b2, b3) () Source #

unit :: FreeUnital a f => a -> f a Source #

Insert an element into an algebra.

>>> V4 1 2 3 4 .*. unit two :: V4 Int
V4 2 4 6 8

unit' :: FreeUnital a f => f a Source #

Unital element of a unital algebra over a free semimodule.

>>> unit one :: Complex Int
1 :+ 0

Coalgebras

type FreeCoalgebra a f = (FreeSemimodule a f, Coalgebra a (Rep f)) Source #

A coalgebra over a free semimodule f.

class Semiring a => Coalgebra a c where Source #

A coalgebra over a semiring.

Minimal complete definition

Nothing

Methods

cojoined :: (c -> a) -> c -> c -> a Source #

codiagonal :: Tran a (c, c) c Source #

lmap' ((c1,c2) -> ((c1,()),(c2,()))) $ (id *** coinitial) . codiagonal = id
lmap' ((c1,c2) -> (((),c1),((),c2))) $ (coinitial *** id) . codiagonal = id
Instances
Semiring a => Coalgebra a IntSet Source #

The free commutative band coalgebra over Int

Instance details

Defined in Data.Semimodule.Algebra

Semiring a => Coalgebra a () Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

cojoined :: (() -> a) -> () -> () -> a Source #

codiagonal :: Tran a ((), ()) () Source #

Semiring r => Coalgebra r E4 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

cojoined :: (E4 -> r) -> E4 -> E4 -> r Source #

codiagonal :: Tran r (E4, E4) E4 Source #

Semiring r => Coalgebra r E3 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

cojoined :: (E3 -> r) -> E3 -> E3 -> r Source #

codiagonal :: Tran r (E3, E3) E3 Source #

Semiring r => Coalgebra r E2 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

cojoined :: (E2 -> r) -> E2 -> E2 -> r Source #

codiagonal :: Tran r (E2, E2) E2 Source #

Semiring r => Coalgebra r E1 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

cojoined :: (E1 -> r) -> E1 -> E1 -> r Source #

codiagonal :: Tran r (E1, E1) E1 Source #

(Semiring a, Ord c) => Coalgebra a (Set c) Source #

The free commutative band coalgebra

Instance details

Defined in Data.Semimodule.Algebra

Methods

cojoined :: (Set c -> a) -> Set c -> Set c -> a Source #

codiagonal :: Tran a (Set c, Set c) (Set c) Source #

Semiring a => Coalgebra a (Seq c) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

cojoined :: (Seq c -> a) -> Seq c -> Seq c -> a Source #

codiagonal :: Tran a (Seq c, Seq c) (Seq c) Source #

Semiring a => Coalgebra a [c] Source #

The tensor coalgebra on c.

Instance details

Defined in Data.Semimodule.Algebra

Methods

cojoined :: ([c] -> a) -> [c] -> [c] -> a Source #

codiagonal :: Tran a ([c], [c]) [c] Source #

Algebra a b => Coalgebra a (b -> a) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

cojoined :: ((b -> a) -> a) -> (b -> a) -> (b -> a) -> a Source #

codiagonal :: Tran a (b -> a, b -> a) (b -> a) Source #

(Coalgebra a c1, Coalgebra a c2) => Coalgebra a (c1, c2) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

cojoined :: ((c1, c2) -> a) -> (c1, c2) -> (c1, c2) -> a Source #

codiagonal :: Tran a ((c1, c2), (c1, c2)) (c1, c2) Source #

(Coalgebra a c1, Coalgebra a c2, Coalgebra a c3) => Coalgebra a (c1, c2, c3) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

cojoined :: ((c1, c2, c3) -> a) -> (c1, c2, c3) -> (c1, c2, c3) -> a Source #

codiagonal :: Tran a ((c1, c2, c3), (c1, c2, c3)) (c1, c2, c3) Source #

codiag :: FreeCoalgebra a f => f a -> (f ** f) a Source #

Obtain a tensor from a vector.

When the coalgebra is trivial we have:

 codiag = flip bindRep id . getCompose

convolve :: Algebra a b => Coalgebra a c => Tran a b c -> Tran a b c -> Tran a b c Source #

Convolution with an associative algebra and coassociative coalgebra

Unital Coalgebras

type FreeCounital a f = (FreeCoalgebra a f, Counital a (Rep f)) Source #

A counital coalgebra over a free semimodule f.

class Coalgebra a c => Counital a c where Source #

A counital coalgebra over a semiring.

Minimal complete definition

Nothing

Methods

counital :: (c -> a) -> a Source #

coinitial :: Tran a () c Source #

Instances
Semiring a => Counital a IntSet Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

counital :: (IntSet -> a) -> a Source #

coinitial :: Tran a () IntSet Source #

Semiring a => Counital a () Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

counital :: (() -> a) -> a Source #

coinitial :: Tran a () () Source #

Semiring r => Counital r E4 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

counital :: (E4 -> r) -> r Source #

coinitial :: Tran r () E4 Source #

Semiring r => Counital r E3 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

counital :: (E3 -> r) -> r Source #

coinitial :: Tran r () E3 Source #

Semiring r => Counital r E2 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

counital :: (E2 -> r) -> r Source #

coinitial :: Tran r () E2 Source #

Semiring r => Counital r E1 Source # 
Instance details

Defined in Data.Semimodule.Basis

Methods

counital :: (E1 -> r) -> r Source #

coinitial :: Tran r () E1 Source #

(Semiring a, Ord c) => Counital a (Set c) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

counital :: (Set c -> a) -> a Source #

coinitial :: Tran a () (Set c) Source #

Semiring a => Counital a (Seq c) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

counital :: (Seq c -> a) -> a Source #

coinitial :: Tran a () (Seq c) Source #

Semiring a => Counital a [c] Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

counital :: ([c] -> a) -> a Source #

coinitial :: Tran a () [c] Source #

Unital a b => Counital a (b -> a) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

counital :: ((b -> a) -> a) -> a Source #

coinitial :: Tran a () (b -> a) Source #

(Counital a c1, Counital a c2) => Counital a (c1, c2) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

counital :: ((c1, c2) -> a) -> a Source #

coinitial :: Tran a () (c1, c2) Source #

(Counital a c1, Counital a c2, Counital a c3) => Counital a (c1, c2, c3) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

counital :: ((c1, c2, c3) -> a) -> a Source #

coinitial :: Tran a () (c1, c2, c3) Source #

counit :: FreeCounital a f => f a -> a Source #

Obtain an element from a coalgebra over a free semimodule.

Bialgebras

type FreeBialgebra a f = (FreeAlgebra a f, FreeCoalgebra a f, Bialgebra a (Rep f)) Source #

A bialgebra over a free semimodule f.

class (Unital a b, Counital a b) => Bialgebra a b Source #

A bialgebra over a semiring.

Instances
Semiring a => Bialgebra a () Source # 
Instance details

Defined in Data.Semimodule.Algebra

Semiring r => Bialgebra r E4 Source # 
Instance details

Defined in Data.Semimodule.Basis

Semiring r => Bialgebra r E3 Source # 
Instance details

Defined in Data.Semimodule.Basis

Semiring r => Bialgebra r E2 Source # 
Instance details

Defined in Data.Semimodule.Basis

Semiring r => Bialgebra r E1 Source # 
Instance details

Defined in Data.Semimodule.Basis

Semiring a => Bialgebra a (Seq b) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Semiring a => Bialgebra a [b] Source # 
Instance details

Defined in Data.Semimodule.Algebra

(Bialgebra a b1, Bialgebra a b2) => Bialgebra a (b1, b2) Source # 
Instance details

Defined in Data.Semimodule.Algebra

(Bialgebra a b1, Bialgebra a b2, Bialgebra a b3) => Bialgebra a (b1, b2, b3) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Tran

newtype Tran a b c Source #

A linear transformation between free semimodules indexed with bases b and c.

f !# x + y = (f !# x) + (f !# y)
f !# (r .* x) = r .* (f !# x)

Caution: You must ensure these laws hold when using the default constructor.

Prefer image or tran where appropriate.

Constructors

Tran 

Fields

Instances
RightSemimodule r s => RightSemimodule r (Tran s b m) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

rscale :: r -> Tran s b m -> Tran s b m Source #

LeftSemimodule r s => LeftSemimodule r (Tran s b m) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

lscale :: r -> Tran s b m -> Tran s b m Source #

Coalgebra a c => Semigroup (Multiplicative (Tran a b c)) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

(<>) :: Multiplicative (Tran a b c) -> Multiplicative (Tran a b c) -> Multiplicative (Tran a b c) #

sconcat :: NonEmpty (Multiplicative (Tran a b c)) -> Multiplicative (Tran a b c) #

stimes :: Integral b0 => b0 -> Multiplicative (Tran a b c) -> Multiplicative (Tran a b c) #

(Additive - Semigroup) a => Semigroup (Additive (Tran a b c)) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

(<>) :: Additive (Tran a b c) -> Additive (Tran a b c) -> Additive (Tran a b c) #

sconcat :: NonEmpty (Additive (Tran a b c)) -> Additive (Tran a b c) #

stimes :: Integral b0 => b0 -> Additive (Tran a b c) -> Additive (Tran a b c) #

Counital a c => Monoid (Multiplicative (Tran a b c)) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

mempty :: Multiplicative (Tran a b c) #

mappend :: Multiplicative (Tran a b c) -> Multiplicative (Tran a b c) -> Multiplicative (Tran a b c) #

mconcat :: [Multiplicative (Tran a b c)] -> Multiplicative (Tran a b c) #

(Additive - Monoid) a => Monoid (Additive (Tran a b c)) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

mempty :: Additive (Tran a b c) #

mappend :: Additive (Tran a b c) -> Additive (Tran a b c) -> Additive (Tran a b c) #

mconcat :: [Additive (Tran a b c)] -> Additive (Tran a b c) #

Arrow (Tran a) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

arr :: (b -> c) -> Tran a b c #

first :: Tran a b c -> Tran a (b, d) (c, d) #

second :: Tran a b c -> Tran a (d, b) (d, c) #

(***) :: Tran a b c -> Tran a b' c' -> Tran a (b, b') (c, c') #

(&&&) :: Tran a b c -> Tran a b c' -> Tran a b (c, c') #

(Additive - Monoid) a => ArrowZero (Tran a) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

zeroArrow :: Tran a b c #

(Additive - Monoid) a => ArrowPlus (Tran a) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

(<+>) :: Tran a b c -> Tran a b c -> Tran a b c #

ArrowChoice (Tran a) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

left :: Tran a b c -> Tran a (Either b d) (Either c d) #

right :: Tran a b c -> Tran a (Either d b) (Either d c) #

(+++) :: Tran a b c -> Tran a b' c' -> Tran a (Either b b') (Either c c') #

(|||) :: Tran a b d -> Tran a c d -> Tran a (Either b c) d #

ArrowApply (Tran a) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

app :: Tran a (Tran a b c, b) c #

(Additive - Group) a => Group (Additive (Tran a b c)) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

inv :: Additive (Tran a b c) -> Additive (Tran a b c) #

greplicate :: Integer -> Additive (Tran a b c) -> Additive (Tran a b c) #

(Additive - Group) a => Loop (Additive (Tran a b c)) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

lempty :: Additive (Tran a b c) #

lreplicate :: Natural -> Additive (Tran a b c) -> Additive (Tran a b c) #

(Additive - Group) a => Quasigroup (Additive (Tran a b c)) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

(//) :: Additive (Tran a b c) -> Additive (Tran a b c) -> Additive (Tran a b c) #

(\\) :: Additive (Tran a b c) -> Additive (Tran a b c) -> Additive (Tran a b c) #

(Additive - Group) a => Magma (Additive (Tran a b c)) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

(<<) :: Additive (Tran a b c) -> Additive (Tran a b c) -> Additive (Tran a b c) #

Category (Tran a :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

id :: Tran a a0 a0 #

(.) :: Tran a b c -> Tran a a0 b -> Tran a a0 c #

Monad (Tran a b) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

(>>=) :: Tran a b a0 -> (a0 -> Tran a b b0) -> Tran a b b0 #

(>>) :: Tran a b a0 -> Tran a b b0 -> Tran a b b0 #

return :: a0 -> Tran a b a0 #

fail :: String -> Tran a b a0 #

Functor (Tran a b) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

fmap :: (a0 -> b0) -> Tran a b a0 -> Tran a b b0 #

(<$) :: a0 -> Tran a b b0 -> Tran a b a0 #

Applicative (Tran a b) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

pure :: a0 -> Tran a b a0 #

(<*>) :: Tran a b (a0 -> b0) -> Tran a b a0 -> Tran a b b0 #

liftA2 :: (a0 -> b0 -> c) -> Tran a b a0 -> Tran a b b0 -> Tran a b c #

(*>) :: Tran a b a0 -> Tran a b b0 -> Tran a b b0 #

(<*) :: Tran a b a0 -> Tran a b b0 -> Tran a b a0 #

(Ring a, Counital a c) => Ring (Tran a b c) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Counital a c => Semiring (Tran a b c) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Coalgebra a c => Presemiring (Tran a b c) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Counital a m => RightSemimodule (Tran a b m) (Tran a b m) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

rscale :: Tran a b m -> Tran a b m -> Tran a b m Source #

Counital a m => LeftSemimodule (Tran a b m) (Tran a b m) Source # 
Instance details

Defined in Data.Semimodule.Algebra

Methods

lscale :: Tran a b m -> Tran a b m -> Tran a b m Source #

type Endo a b = Tran a b b Source #

An endomorphism over a free semimodule.

>>> one + two !# V2 1 2 :: V2 Double
V2 3.0 6.0

image :: Semiring a => (b -> [(a, c)]) -> Tran a b c Source #

Create a Tran from a linear combination of basis vectors.

>>> image (e2 [(2, E31),(3, E32)] [(1, E33)]) !# V3 1 1 1 :: V2 Int
V2 5 1

(!#) :: Free f => Free g => Tran a (Rep f) (Rep g) -> g a -> f a infixr 2 Source #

Apply a transformation to a vector.

(#!) :: Free f => Free g => g a -> Tran a (Rep f) (Rep g) -> f a infixl 2 Source #

Apply a transformation to a vector.

(!#!) :: Tran a c d -> Tran a b c -> Tran a b d infix 2 Source #

Compose two transformations.

dimap' :: (b1 -> b2) -> (c1 -> c2) -> Tran a b2 c1 -> Tran a b1 c2 Source #

Tran is a profunctor in the category of semimodules.

Caution: Arbitrary mapping functions may violate linearity.

>>> dimap' id (e3 True True False) (arr id) !# 4 :+ 5 :: V3 Int
V3 5 5 4

lmap' :: (b1 -> b2) -> Tran a b2 c -> Tran a b1 c Source #

rmap' :: (c1 -> c2) -> Tran a b c1 -> Tran a b c2 Source #

invmap :: (a1 -> a2) -> (a2 -> a1) -> Tran a1 b c -> Tran a2 b c Source #

Tran is an invariant functor.

See also http://comonad.com/reader/2008/rotten-bananas/.

Common linear transformations

braid :: Tran a (b, c) (c, b) Source #

Swap components of a tensor product.

cobraid :: Tran a (b + c) (c + b) Source #

Swap components of a direct sum.

split :: (b -> (b1, b2)) -> Tran a b1 c -> Tran a b2 c -> Tran a b c Source #

TODO: Document

cosplit :: ((c1 + c2) -> c) -> Tran a b c1 -> Tran a b c2 -> Tran a b c Source #

TODO: Document

projl :: Free f => Free g => (f ++ g) a -> f a Source #

Project onto the left-hand component of a direct sum.

projr :: Free f => Free g => (f ++ g) a -> g a Source #

Project onto the right-hand component of a direct sum.

compl :: Free f1 => Free f2 => Free g => Tran a (Rep f1) (Rep f2) -> (f2 ** g) a -> (f1 ** g) a Source #

Left (post) composition with a linear transformation.

compr :: Free f => Free g1 => Free g2 => Tran a (Rep g1) (Rep g2) -> (f ** g2) a -> (f ** g1) a Source #

Right (pre) composition with a linear transformation.

complr :: Free f1 => Free f2 => Free g1 => Free g2 => Tran a (Rep f1) (Rep f2) -> Tran a (Rep g1) (Rep g2) -> (f2 ** g2) a -> (f1 ** g1) a Source #

Left and right composition with a linear transformation.

 complr f g = compl f >>> compr g