generic

class tinychain.generic.Map(*args, **kwargs)[source]

Bases: State, Generic[T]

A key-value map whose keys are Id s and whose values are :class: State s.

eq(other)[source]

Return a Bool indicating whether all the keys and values in this map are equal to the given other.

len()[source]

Return the number of elements in this Map.

ne(other)[source]

Return a Bool indicating whether the keys and values in this Map are not equal to the given other.

class tinychain.generic.MapRef(state, name)[source]

Bases: StateRef

A named reference to a Map.

class tinychain.generic.Tuple(form)[source]

Bases: State, Functional, Generic[T]

A tuple of State s.

contains(item)[source]

Return a Bool indicating whether the given item is present in this Tuple.

eq(other)[source]

Return a Bool indicating whether all elements in this Tuple equal those in the given other.

len()[source]

Return the number of elements in this Tuple.

ne(other)[source]

Return a Bool indicating whether the elements in this Tuple do not equal those in other.

This is implemented as self.eq(other).logical_not().

classmethod range(range)[source]

Construct a new Tuple of Number s in the given range.

range can be a positive Number, (start, stop), or (start, stop, step)

unpack(length)[source]

A Python convenience method which yields an iterator over the first length elements in this Tuple.

zip(other)[source]

Construct a new Tuple of 2-tuples of the form (self[i], other[i]) for i in self.len().

class tinychain.generic.TupleRef(state, name)[source]

Bases: StateRef

A named reference to a Tuple.

tinychain.generic.autobox(state)[source]

Given a Python literal, box it in the appropriate type of State.

For example, autobox(1) will return Int(1), autobox({‘a’: 3.14}) will return a Map[Float], etc.

tinychain.generic.gcs(*types)[source]

Get the greatest common superclass of a list of types

tinychain.generic.resolve_class(type_hint)[source]

Given a generic type hint, attempt to resolve it to a callable class constructor.

tinychain.generic.resolve_interface(cls)[source]

Construct a subclass of State which implements the given Interface.