Ty#
- class discopy.stream.Ty(now=None, _later=None)[source]#
Bases:
NamedGeneric['base']
A stream of types from some underlying class base.
- Parameters:
now (base) – The value of the stream at time step zero.
_later (Optional[Callable[[], Ty[base]]]) – A thunk for the tail of the stream, constant by default.
- property later: Ty#
The tail of a stream, or self if
is_constant()
.
- property head: Ty#
The
singleton()
over the first time step.
- property tail: Ty#
The tail of a stream, or self if
is_constant()
.
- property is_constant: bool#
Whether a stream of type is constant.
- classmethod singleton(x)[source]#
Constructs the stream with x now and the empty stream later.
>>> XY = Ty.singleton(symmetric.Ty('x', 'y')) >>> for x in [XY.now, XY.later.now, XY.later.later.now]: print(x) x @ y Ty() Ty()
- Parameters:
x (base) –
- Return type:
- delay()[source]#
Delays a stream of types by pre-pending with the unit.
>>> XY = Ty(symmetric.Ty('x', 'y')).delay() >>> for x in [XY.now, XY.later.now, XY.later.later.now]: print(x) Ty() x @ y x @ y
- Return type:
- classmethod sequence(x, n_steps=0)[source]#
Constructs the stream x0, x1, etc.
>>> XY = Ty.sequence(symmetric.Ty('x', 'y')) >>> for x in [XY.now, XY.later.now, XY.later.later.now]: print(x) x0 @ y0 x1 @ y1 x2 @ y2
- Parameters:
x (base) –
n_steps (int) –
- Return type: