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 and y.

copy(x[, n])

The function for making n copies of a tuple of types x.

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, …]

tensor(other)[source]#

The parallel composition of two functions, called with @.

Parameters:

other (Function) – The other function to compose in sequence.

Return type:

Function

static swap(x, y)[source]#

The function for swapping two tuples of types x and y.

Parameters:
  • x (tuple[type, ...]) – The tuple of types on the left.

  • y (tuple[type, ...]) – The tuple of types on the right.

Return type:

Function

static braid(x, y)#

The function for swapping two tuples of types x and y.

Parameters:
  • x (tuple[type, ...]) – The tuple of types on the left.

  • y (tuple[type, ...]) – The tuple of types on the right.

Return type:

Function

static copy(x, n=2)[source]#

The function for making n copies of a tuple of types x.

Parameters:
  • x (tuple[type, ...]) – The tuple of types to copy.

  • n – The number of copies.

Return type:

Function

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:

Function

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:

Function

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:

Function

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:

Function

fix(n=1)[source]#

The parameterised fixed point of a function.

Parameters:

n – The number of types to take the fixed point over.

Return type:

Function

trace(n=1, left=False)[source]#

The multiplicative trace of a function.

Parameters:

n – The number of types to trace over.