Function#
- class discopy.python.multiplicative.Function(inside, dom, cod)[source]#
Bases:
discopy.python.function.Function
Python function with tuple as tensor.
- Parameters:
inside (Callable) – The callable Python object inside the function.
dom (type) – The domain of the function, i.e. its list of input types.
cod (type) – The codomain of the function, i.e. its list of output types.
Summary
tensor
(other)The parallel composition of two functions, called with
@
.swap
(x, y)The function for swapping two tuples of types
x
andy
.copy
(x[, n])The function for making
n
copies of a tuple of typesx
.discard
(dom)The function discarding a tuple of types, i.e. making zero copies.
ev
(base, exponent[, left])The evaluation function, i.e. take a function and apply it to an argument.
curry
([n, left])Currying, i.e. turn a binary function into a function-valued function.
uncurry
([left])Uncurrying, i.e. turn a function-valued function into a binary function.
fix
([n])The parameterised fixed point of a function.
trace
([n, left])The multiplicative trace of a function.
- ty_factory#
alias of
tuple
[type
, …]
- static swap(x, y)[source]#
The function for swapping two tuples of types
x
andy
.- Parameters:
x (tuple[type, ...]) – The tuple of types on the left.
y (tuple[type, ...]) – The tuple of types on the right.
- Return type:
- static braid(x, y)#
The function for swapping two tuples of types
x
andy
.- Parameters:
x (tuple[type, ...]) – The tuple of types on the left.
y (tuple[type, ...]) – The tuple of types on the right.
- Return type:
- static copy(x, n=2)[source]#
The function for making
n
copies of a tuple of typesx
.- Parameters:
x (tuple[type, ...]) – The tuple of types to copy.
n – The number of copies.
- Return type:
- static discard(dom)[source]#
The function discarding a tuple of types, i.e. making zero copies.
- Parameters:
dom (tuple[type, ...]) – The tuple of types to discard.
- Return type:
- static ev(base, exponent, left=True)[source]#
The evaluation function, i.e. take a function and apply it to an argument.
- Parameters:
base (tuple[type, ...]) – The output type.
exponent (tuple[type, ...]) – The input type.
left – Whether to take the function on the left or right.
- Return type:
- curry(n=1, left=True)[source]#
Currying, i.e. turn a binary function into a function-valued function.
- Parameters:
n – The number of types to curry.
left – Whether to curry on the left or right.
- Return type:
- uncurry(left=True)[source]#
Uncurrying, i.e. turn a function-valued function into a binary function.
- Parameters:
left – Whether to uncurry on the left or right.
- Return type: