curry.toolchain.flat2icurry.compiler module

The name-to-index maps and the ICurry generation, the last two passes. They follow ICurry.Compiler and the map functions of ICurry.Options of the Curry package icurry.

Each ICurry name is a triple (module, name, index). A constructor’s index is its position in its data type. A data type’s index is its position in the type list of its module, type synonyms counted. The public functions of a module are numbered from 0 in order of appearance. The private ones, the lifted functions included, continue the numbering in the order of the lifted program.

class curry.toolchain.flat2icurry.compiler.NameMaps[source]

Bases: object

Maps qualified names to their ICurry indices.

add_constructors(prog)[source]
add_public_functions(prog)[source]
arity_pos_of_cons(qn, fun='')[source]
classmethod build(prog, impprogs, liftedprog)[source]

Builds the maps for prog (after newtype elimination), its imports, and the lifted program, whose private functions follow the public ones.

pos_of_cons(qn, fun='')[source]
pos_of_fun(qn, fun='')[source]
curry.toolchain.flat2icurry.compiler.demand_of(rule, icurry_compat=True)[source]

The argument a rule demands: the one its root case scrutinizes. icurry 3.1.0 does not look through a type annotation around the case. Without icurry_compat the annotation is removed first.

curry.toolchain.flat2icurry.compiler.flat2icurry(maps, prog, icurry_compat=True)[source]

Translates a completed and lifted FlatCurry program to ICurry.

icurry_compat keeps the output of icurry 3.1.0 for a type annotation at the root of a rule. See to_iblock().

curry.toolchain.flat2icurry.compiler.strip_typed(e)[source]

The expression under any type annotations.

curry.toolchain.flat2icurry.compiler.var_pos(rpos, e)[source]

The variables of an ICurry expression with their positions, in the order of the expression. The walk keeps its own stack, so a nested application of any depth needs no recursion.