eyg/analysis/inference/levels_j/contextual

Types

pub type Analysis(meta) {
  Analysis(
    bindings: dict.Dict(Int, binding.Binding),
    tree: #(
      tree.Expression(
        #(
          Result(Nil, error.Reason),
          isomorphic.Type(Int),
          isomorphic.Type(Int),
          List(#(String, isomorphic.Type(#(Bool, Int)))),
        ),
      ),
      #(
        Result(Nil, error.Reason),
        isomorphic.Type(Int),
        isomorphic.Type(Int),
        List(#(String, isomorphic.Type(#(Bool, Int)))),
      ),
    ),
    original: #(tree.Expression(meta), meta),
  )
}

Constructors

pub type Context {
  Context(
    env: List(#(String, isomorphic.Type(#(Bool, Int)))),
    eff: isomorphic.Type(Int),
    level: Int,
    bindings: dict.Dict(Int, binding.Binding),
    expected_type: option.Option(isomorphic.Type(Int)),
  )
}

Constructors

pub type Env =
  List(#(String, isomorphic.Type(#(Bool, Int))))
pub type Step(a) {
  Done(a)
  Lookup(
    reference: tree.Reference,
    resume: fn(Result(isomorphic.Type(#(Bool, Int)), Nil)) -> Step(
      a,
    ),
  )
}

Constructors

Values

pub fn all_errors(
  inference: Analysis(meta),
) -> List(#(meta, error.Reason))
pub fn arity_at(
  inference: Analysis(meta),
  desired: meta,
) -> Result(Int, Nil)
pub fn bind(step: Step(a), f: fn(a) -> Step(b)) -> Step(b)
pub fn builtins() -> List(
  #(String, isomorphic.Type(#(Bool, Int))),
)
pub fn case_(label: String) -> isomorphic.Type(#(Bool, Int))
pub fn check(
  context: Context,
  source: #(tree.Expression(a), a),
) -> Step(Analysis(a))
pub fn check_with_references(
  context: Context,
  refs: dict.Dict(v1.Cid, isomorphic.Type(#(Bool, Int))),
  source: #(tree.Expression(a), a),
) -> Analysis(a)
pub fn count_args(type_: isomorphic.Type(a)) -> Result(Int, Nil)
pub fn do_infer(
  source: #(tree.Expression(a), a),
  env: List(#(String, isomorphic.Type(#(Bool, Int)))),
  eff: isomorphic.Type(Int),
  level: Int,
  bindings: dict.Dict(Int, binding.Binding),
) -> Step(
  #(
    dict.Dict(Int, binding.Binding),
    isomorphic.Type(Int),
    isomorphic.Type(Int),
    #(
      tree.Expression(
        #(
          Result(Nil, error.Reason),
          isomorphic.Type(Int),
          isomorphic.Type(Int),
          List(#(String, isomorphic.Type(#(Bool, Int)))),
        ),
      ),
      #(
        Result(Nil, error.Reason),
        isomorphic.Type(Int),
        isomorphic.Type(Int),
        List(#(String, isomorphic.Type(#(Bool, Int)))),
      ),
    ),
  ),
)
pub fn fix() -> isomorphic.Type(#(Bool, Int))
pub fn ftv(type_: isomorphic.Type(a)) -> set.Set(a)
pub fn handle(label: String) -> isomorphic.Type(#(Bool, Int))
pub fn missing_references(
  inference: Analysis(meta),
) -> List(tree.Reference)
pub fn nocases() -> isomorphic.Type(#(Bool, Int))
pub fn poly_type(
  inference: Analysis(meta),
) -> isomorphic.Type(#(Bool, Int))
pub fn pure() -> Context

pure creates a new inference context to infer an expression with no effects. Any effect from the expression will be a type error

pub fn q(i: a) -> isomorphic.Type(#(Bool, a))
pub fn scope_at(
  inference: Analysis(meta),
  desired: meta,
) -> Result(List(#(String, isomorphic.Type(#(Bool, Int)))), Nil)
pub fn type_(inference: Analysis(meta)) -> isomorphic.Type(Int)

Returns the top type from the analysis over an expression

pub fn type_at(
  inference: Analysis(meta),
  desired: meta,
) -> Result(isomorphic.Type(Int), Nil)
pub fn unpure() -> Context

unpure creates a new inference context which accepts any effect.

pub fn with_effect(
  context: Context,
  label: String,
  lift: isomorphic.Type(Int),
  lower: isomorphic.Type(Int),
) -> Context
pub fn with_effects(
  context: Context,
  effects: List(
    #(String, #(isomorphic.Type(Int), isomorphic.Type(Int))),
  ),
) -> Context
pub fn with_expected_type(
  context: Context,
  expected: isomorphic.Type(Int),
) -> Context

Require the expression’s result to match this monotype. The caller must register its variables in the context’s bindings, as with scope and effect types. Calling this again replaces the previous expectation.

✨ Search Document