scenic.core.type_support

Support for checking Scenic types.

Summary of Module Members

Functions

canCoerce

Can this value be coerced into the given type?

canCoerceType

Can values of typeA be coerced into typeB?

coerce

Coerce something into the given type.

coerceToAny

Coerce something into any of the given types, printing an error if impossible.

evaluateRequiringEqualTypes

Evaluate the func, assuming thingA and thingB have the same type.

isA

Does this evaluate to a member of the given Scenic type?

toHeading

Convert something to a heading, printing an error if impossible.

toScalar

Convert something to a scalar, printing an error if impossible.

toType

Convert something to a given type, printing an error if impossible.

toTypes

Convert something to any of the given types, printing an error if impossible.

toVector

Convert something to a vector, printing an error if impossible.

underlyingType

What type this value ultimately evaluates to, if we can tell.

unifyingType

Most specific type unifying the given types.

Classes

Heading

Dummy class used as a target for type coercions to headings.

TypeChecker

Checks that a given lazy value has one of a given list of types.

TypeEqualityChecker

Lazily evaluates a function, after checking that two lazy values have the same type.

Member Details

class Heading[source]

Bases: object

Dummy class used as a target for type coercions to headings.

underlyingType(thing)[source]

What type this value ultimately evaluates to, if we can tell.

isA(thing, ty)[source]

Does this evaluate to a member of the given Scenic type?

unifyingType(opts)[source]

Most specific type unifying the given types.

canCoerceType(typeA, typeB)[source]

Can values of typeA be coerced into typeB?

canCoerce(thing, ty)[source]

Can this value be coerced into the given type?

coerce(thing, ty)[source]

Coerce something into the given type.

coerceToAny(thing, types, error)[source]

Coerce something into any of the given types, printing an error if impossible.

toTypes(thing, types, typeError='wrong type')[source]

Convert something to any of the given types, printing an error if impossible.

toType(thing, ty, typeError='wrong type')[source]

Convert something to a given type, printing an error if impossible.

toScalar(thing, typeError='non-scalar in scalar context')[source]

Convert something to a scalar, printing an error if impossible.

toHeading(thing, typeError='non-heading in heading context')[source]

Convert something to a heading, printing an error if impossible.

toVector(thing, typeError='non-vector in vector context')[source]

Convert something to a vector, printing an error if impossible.

evaluateRequiringEqualTypes(func, thingA, thingB, typeError='type mismatch')[source]

Evaluate the func, assuming thingA and thingB have the same type.

If func produces a lazy value, it should not have any required properties beyond those of thingA and thingB.

class TypeChecker(arg, types, error)[source]

Bases: scenic.core.lazy_eval.DelayedArgument

Checks that a given lazy value has one of a given list of types.

class TypeEqualityChecker(func, checkA, checkB, error)[source]

Bases: scenic.core.lazy_eval.DelayedArgument

Lazily evaluates a function, after checking that two lazy values have the same type.