meta
- class Kind(name, bases, dct)
Type kinds.
Subclasses of
Kindmay register class method signatures with the@Methoddecorator, 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 valueT(*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:
- 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
- var()
Return constructor instance acting on type variables.
- Return type:
- 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
- var()
Return constructor instance acting on type variables.
- Return type:
- 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
- var()
Return constructor instance acting on type variables.
- Return type:
- class Functor(name, bases, dct)
Covariant functors.
- arity: int = 1
- fmap
Map a source arrow
A -> Bto a target arrowT(A) -> T(B).
- property kind: str
String representation of functor signature.
- methods()
Method signatures.
- mro()
Return a type’s method resolution order.
- new
- var()
Return constructor instance acting on type variables.
- Return type:
- 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
- var()
Return constructor instance acting on type variables.
- Return type:
- class NFunctor(name, bases, dct)
Functors with arbitrary signatures.
- arity: int = Ellipsis
- fmap
Map a source arrow
A -> Bto a target arrowT(A) -> T(B).
- kind = '(*, ...) -> *'
- methods()
Method signatures.
- mro()
Return a type’s method resolution order.
- new
- var()
Return constructor instance acting on type variables.
- Return type:
- class Monad(name, bases, dct)
Monads.
A monad is a monoid in the category of functors
Type -> Type.The
joinoperation 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 -> Bto a target arrowT(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
- unit
- var()
Return constructor instance acting on type variables.
- Return type:
- 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
Typeand its monoidal operation*(cartesian product).- arity: int = 1
- fmap
Map a source arrow
A -> Bto a target arrowT(A) -> T(B).
- property kind: str
String representation of functor signature.
- lift2
- methods()
Method signatures.
- mro()
Return a type’s method resolution order.
- new
- unit
- var()
Return constructor instance acting on type variables.
- Return type: