Function hindley_milner::analyse [] [src]

pub fn analyse(
    a: &mut Vec<Type>,
    node: &Syntax,
    env: &Env,
    non_generic: &HashSet<ArenaType>
) -> ArenaType

Computes the type of the expression given by node.

The type of the node is computed in the context of the supplied type environment env. Data types can be introduced into the language simply by having a predefined set of identifiers in the initial environment. environment; this way there is no need to change the syntax or, more importantly, the type-checking program when extending the language.

Args: node: The root of the abstract syntax tree. env: The type environment is a mapping of expression identifier names to type assignments. non_generic: A set of non-generic variables, or None

Returns: The computed type of the expression.

Raises: InferenceError: The type of the expression could not be inferred, for example if it is not possible to unify two types such as Integer and Bool ParseError: The abstract syntax tree rooted at node could not be parsed