next node: PrettyPrintBuiltin,
prev node: ReflectionLookup,
up to node: User Subsystem : Reflections


ReflectionInspect

InspectionInterface

Signature of ReflectionInspect

List of Import References :
See Reflection

SIGNATURE ReflectionInspect

IMPORT Reflection   ONLY sort : SORT name : SORT value : SORT type : SORT
       Seq[value]   ONLY seq
       Seq[variant] ONLY seq
       Seq[type]    ONLY seq

This structure introduces types and functions for inspecting values on the base of free type information. Given a sort, the function freeType? test whether its argument has an associated free type definition. The function variants delivers the variants for a sort which represents a free type (or an empty list for opaque types). A variant is described by an aggregate of the variant's constructor function's name, the types of its components and a set of functions working on reflections. The constructor function, which takes an appropriately typed components argument, constructs a value from its argument. The boolean discriminator function tests whether its argument is constructed from this variant. Finally, the deconstructor function decomposes a value of this variant into its components.

TYPE variant == variant(constructorName : name,
                        components      : seq[type],
                        constructor     : value -> value,
                        discriminator   : value -> bool,
                        deconstructor   : value -> value)

FUN freeType?   : sort           -> bool
FUN variants    : sort           -> seq[variant]

FUN freeType?   : type           -> bool
FUN variants    : type           -> seq[variant]

The tuple and untuple functions allow to construct and deconstruct reflected tuple values. Tupling on a singleton sequence yields the element, and untupling of a non-tuple yields a singleton sequence.

FUN tuple       : seq[value]     -> value
FUN untuple     : value          -> seq[value]

The expression applicable(f, x) tests whether f is a reflected function that can be applied to the reflected argument x. The expression apply(f, x) yields the reflected result of this application.

FUN applicable? : value ** value -> bool
FUN apply       : value ** value -> value


next node: PrettyPrintBuiltin,
prev node: ReflectionLookup,
up to node: User Subsystem : Reflections