Documentation

Strata.DL.Imperative.PureExpr

Expected interface for pure expressions that can be used to specialize the Imperative dialect.

  • Ident : Type

    Kinds of identifiers allowed in expressions. We expect identifiers to have decidable equality; see EqIdent.

  • EqIdent : DecidableEq self.Ident

    Decidable equality on identifiers.

  • Expr : Type

    Expressions

  • Ty : Type

    Types

  • ExprMetadata : Type

    Expression metadata type (for use in function declarations, etc.)

  • TyEnv : Type

    Typing environment, expected to contain a map of variables to their types, type substitution, etc.

  • TyContext : Type

    Typing context, expected to contain information that does not change during type checking/inference (e.g., known types and known functions.)

  • Factory : Type

    Factory for function/operator resolution

  • eval : self.Factory → (self.Ident → Option self.Expr) → self.Expr → Option self.Expr

    The expression evaluator. Takes a factory, a variable store, and an expression, and returns an optional evaluated expression.

Instances For
    @[reducible, inline]
    Equations
    Instances For
      @[reducible, inline]
      Equations
      Instances For

        Type Classes for Expressions #

        Instances

          Lawfulness of HasIdent: the canonical identifier-injection is injective.

          Instances
            • mkFvar : P.Ident → P.Expr
            • mkTypedFvar : P.Ident → P.Ty → P.Expr

              A free variable carrying its type. A pass that introduces a variable after type checking has run must annotate it itself, since nothing downstream will.

            • getFvar : P.Expr → Option P.Ident
            Instances

              Lawfulness of HasFvar: the round-trip getFvar (mkFvar x) = some x.

              Instances

                Multi-variable version of HasFvar.getFvar: returns ALL free variables in a (possibly compound) expression. HasFvar.getFvar only returns Some when the expression is a single fvar atom; HasFvars.getFvars recurses into compounds.

                Instances

                  Lawfulness of HasFvars against HasFvar: the free-variable list of an mkFvar x expression, as computed by the HasFvars.getFvars extractor, is a subset of [x].

                  Instances

                    Returns ALL operator/function names referenced in an expression (e.g., .op constructs in Lambda).

                    Instances
                      Instances

                        Boolean expressions. Extends HasVal P (folding in the former HasBoolVal). boolIsVal ensures tt/ff are values.

                        Instances

                          Boolean operations: not, and, imp.

                          Instances

                            Integer constants and the integer type.

                            Instances

                              Integer arithmetic / comparison primitives.

                              Instances

                                Substitution of free variables in expressions. Used for closure capture in function declarations.

                                • substFvar : P.Expr → P.Ident → P.Expr → P.Expr

                                  Substitute a single free variable with an expression

                                • substFvars : P.Expr → List (P.Ident × P.Expr) → P.Expr

                                  Simultaneously substitute multiple free variables with expressions. Replaces all variables in a single pass, avoiding capture between substitutions.

                                Instances
                                  @[reducible, inline]

                                  A function declaration for use with PureExpr - instantiation of Func for any expression system that implements the PureExpr interface.

                                  Equations
                                  Instances For