Skip to main content

wrap_with_datacon_env

Function wrap_with_datacon_env 

Source
pub fn wrap_with_datacon_env(expr: &CoreExpr, table: &DataConTable) -> CoreExpr
Expand description

Wrap a CoreExpr with let-bindings for all data constructors from the table.

For each DataCon with arity N:

  • arity 0: let dc_var = Con(id, []) in ...
  • arity 1: let dc_var = \v0 -> Con(id, [v0]) in ...
  • arity 2: let dc_var = \v0 -> \v1 -> Con(id, [v0, v1]) in ...
  • etc.

The binding VarId matches VarId(dc.id.0), which is what the GHC Core translator uses to reference data constructors as function values.