meta

class Kind(name, bases, dct)

Type kinds.

Subclasses of Kind may register class method signatures with the @Method decorator, e.g.

>>> class Functor(Type):
...
...     @Method
...     def fmap(F):
...         return Hom('A', 'B'), Hom(F('A'), F('B'))
methods()

Method signatures.

class Constructor(name, bases, dct)

Type constructors.

Instances define a classmethod T.new(*As) returning the type value T(*As) = T A1 ... An.

property kind

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

var()

Return constructor instance acting on type variables.

Return type:

Constructor

class Ellipsis(*xs, **ys)
substitute(matches)

Concrete type obtained by substitution of matches.

class Var(*xs, **ys)
match(B)

Matches {"Ai": Type} against a concrete type B.

substitute(matches)

Concrete type obtained by substitution of matches.

Parameters:

matches (dict[str, Type])

Return type:

Type

class ArrowFunctor(name, bases, dct)

Bifunctors with a composition law.

arity: int = 2
cofmap
compose
fmap
property kind: str

String representation of functor signature.

methods()

Method signatures.

mro()

Return a type’s method resolution order.

new
src: Category
tgt: Category
var()

Return constructor instance acting on type variables.

Return type:

Constructor

class Bifunctor(name, bases, dct)

Functors with both contravariant and covariant arguments.

arity: int = 2
cofmap
fmap
property kind: str

String representation of functor signature.

methods()

Method signatures.

mro()

Return a type’s method resolution order.

new
src: Category
tgt: Category
var()

Return constructor instance acting on type variables.

Return type:

Constructor

class Category(name, bases, dct)
Hom
kind = '*'
methods()

Method signatures.

mro()

Return a type’s method resolution order.

class Cofunctor(name, bases, dct)

Contravariant functors.

arity = 1
cofmap
property kind

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

methods()

Method signatures.

mro()

Return a type’s method resolution order.

new
src: Category
tgt: Category
var()

Return constructor instance acting on type variables.

Return type:

Constructor

class Functor(name, bases, dct)

Covariant functors.

arity: int = 1
fmap

Map a source arrow A -> B to a target arrow T(A) -> T(B).

property kind: str

String representation of functor signature.

methods()

Method signatures.

mro()

Return a type’s method resolution order.

new
src: Category
tgt: Category
var()

Return constructor instance acting on type variables.

Return type:

Constructor

class HomFunctor(name, bases, dct)

Bifunctors with a composition law and an evaluation map.

arity: int = 2
cofmap
compose
eval
fmap
property kind: str

String representation of functor signature.

methods()

Method signatures.

mro()

Return a type’s method resolution order.

new
src: Category
tgt: Category
var()

Return constructor instance acting on type variables.

Return type:

Constructor

class NFunctor(name, bases, dct)

Functors with arbitrary signatures.

arity: int = Ellipsis
fmap

Map a source arrow A -> B to a target arrow T(A) -> T(B).

kind = '(*, ...) -> *'
methods()

Method signatures.

mro()

Return a type’s method resolution order.

new
src: Category
tgt: Category
var()

Return constructor instance acting on type variables.

Return type:

Constructor

class Monad(name, bases, dct)

Monads.

A monad is a monoid in the category of functors Type -> Type.

The join operation is referred to as monadic composition, examples include:

  • flattening of lists, trees, …

  • concatenation of logs, error messages, …

  • subprocess execution, asynchronous await, …

arity: int = 1
bind
fmap

Map a source arrow A -> B to a target arrow T(A) -> T(B).

join
property kind: str

String representation of functor signature.

lift2
methods()

Method signatures.

mro()

Return a type’s method resolution order.

new
src: Category
tgt: Category
unit
var()

Return constructor instance acting on type variables.

Return type:

Constructor

class Monoidal(name, bases, dct)

Monoidal (a.k.a. Applicative) functors.

A functor between two monoidal categories respects their monoidal operations. In functional programming, one is usually concerned with the category Type and its monoidal operation * (cartesian product).

arity: int = 1
fmap

Map a source arrow A -> B to a target arrow T(A) -> T(B).

property kind: str

String representation of functor signature.

lift2
methods()

Method signatures.

mro()

Return a type’s method resolution order.

new
src: Category
tgt: Category
unit
var()

Return constructor instance acting on type variables.

Return type:

Constructor