curry.typecheck.exprtype module

The parser of exprtype strings.

The grammar is a Curry monotype without a context: type variables, constructor names qualified or unqualified, lists, tuples, (), function arrows and parentheses. A constructor name is resolved through the interfaces of the loaded modules: the Type and TypeNew entries of the FlatCurry interface give the data types and their arities, and the type declarations of the Curry interface M.icurry, which travels with the .fint, give the synonyms. The front end expands a synonym in the interface, so one expansion suffices.

parse_type() returns a FlatCurry type whose variables are TVar with the indices of their first occurrence, and the names of the variables. parse_term() returns the term of the engine, with one rigid variable per name.

class curry.typecheck.exprtype.Synonym(modulename, name, params, text)[source]

Bases: object

A type synonym of a module: its parameters and the text of its type.

property arity
modulename
name
params
text
curry.typecheck.exprtype.icurry_filename(fint_filename)[source]

The Curry interface beside a FlatCurry interface.

curry.typecheck.exprtype.parse_term(interp, text, module=None)[source]

Parses an exprtype string into a term of the engine. Each type variable becomes one Rigid.

curry.typecheck.exprtype.parse_type(interp, text, module=None)[source]

Parses an exprtype string.

Parameters:
  • interp – The interpreter whose loaded modules resolve the names.

  • text – The type in Curry syntax, without a context.

  • module – The module whose names are preferred for an unqualified name, or None.

Returns:

the FlatCurry type, whose variables are TVar with the indices of their first occurrence, and a dict from index to name.

Return type:

A pair

Raises:
curry.typecheck.exprtype.synonyms_of(interp, modulename)[source]

The synonyms a module declares, by name, from its .icurry interface. An empty dict for a module without an interface.