Crate fungi_lang

source ·
Expand description

Fungi language: reference implementation in Rust.

See also: example Fungi programs in this Rust implementation.

Syntax

Fungi’s abstract syntax consists of Rust data types; we implement its concrete syntax with Rust macros:

  • ast — Abstract syntax (Rust datatypes)
  • parse — Concrete syntax (Rust macros)

(See examples)

Statics

Fungi’s statics relate Fungi programs with their types and effects.

To accomplish this, Fungi gives a “type-level” semantics for relating types, and their index- and name terms. Specifically, this theory includes various supportive notions:

  • expand — expand type-level definitions,
  • subst — perform type-level variable substitution,
  • normal — perform type-level term normalization,
  • decide — decide relationships about types, and about type indices.
    • equiv – decides term equivalence relationships
    • apart – decides term apartness relationships
    • subset – decide name subsets, and subtyping relationships
    • effect – decide effect sequencing and subtracting relationships

These notions are each in support of

  • bitype — bi-directional type checking for program terms (expressions and values).

In particular, the bitype module synthesizes and checks the types of Fungi program terms, and thus provides the most common “entry points” into the implementation of Fungi’s statics.

Dynamics

Fungi’s dynamics execute Fungi programs, under varying notions of execution.

Fungi’s program executions use Adapton in Rust. We define two reference implementations for Fungi’s dynamics: small-step reduction, and big-step evaluation:

  • reduce – program dynamics as small-step reduction
  • eval – program dynamics as big-step evaluation

These approaches have many common definitions:

  • dynamics – common definitions: name term evaluation, run-time values, and environments.

Dynamics: practicum

Summary: Use program reduction (not evaluation) in all practical settings.

For the sake of completeness, we provide two execution definitions. However, the implementation of small-step reduction is significantly more practical than the version of big-step evaluation given here.

In particular, program reduction avoids using (Rust-level) stack space, whereas the simple evaluation definition here uses the (Rust-level) stack space in proportion to the depth of the full evaluation derivation. These derivations can be deep for recursive, looping programs, where their depth is often the same, asymptotically, as their running time. On the other hand, this definition of evaluation is simple, and easy to read and understand — the goal of its reference implementation; readers are encouraged to read it, not run it (except for very small programs).

Modules

Syntax: abstract (via Rust datatypes) and concrete (via Rust macros).
Bidirectional type system.
Decision procedures for Fungi type and effect system.
Syntax for dynamic, evaluation-time structures.
Evaluation semantics.
Examples of data structures and algorithms in Fungi.
Expand static definitions (Ident cases of types, indices and effects).
Host-level (Rust-level) values as Fungi values
Convert fungi execution traces into HTML files
Static (typing-time) term reduction/normalization.
Syntax: abstract (via Rust datatypes) and concrete (via Rust macros).
Reduction semantics.
Serialization for external data structures contained in Fungi’s bundle format.
a sharing serializes once, not once per reference (c.f. the Rc type).
Static (typing-time) substitutions.
Visualization of ASTs, typings, evaluation, etc.

Macros

Parser for Computations with effects
Parser for computation types
Parser for declaration lists
Parser for Effects
Parser for expressions
Parser for host expressions: the bodies of host functions.
Parser for Index Terms
Declare an inner, named Fungi module, using an inner host (Rust) module.
Parser for Kinds
Fungi program listing that we test.
Declare the Fungi module for current host (Rust) module.
Parser for modules, whose bodies consist of a declaration list.
Parser for Name Literals
Parser for Name Terms
Parser for Propositions
Parser for (run-time) values
Parser for Sorts
Parser for values
Parser for value types
this macro is a helper for fgi_ctype, not for external use
this macro is a helper for fgi_ceffect, not for external use
this macro is a helper for fgi_effect, not for external use
this macro is a helper for fgi_nametm, not for external use
this macro is a helper for fgi_val, not for external use
this macro is a helper for fgi_vtype, not for external use
this macro is a helper for fgi_rtval, not for external use
this macro is a helper for fgi_exp, not for external use
this macro is a helper for fgi_vtype, not for external use
this macro is a helper for fgi_val, not for external use
run a macro on a list of lists after splitting the input
run a macro on a list of lists after splitting the input
run a macro on a list of lists after splitting the input
run a macro on a list of lists after splitting the input
run a macro on a list of lists after splitting the input
run a macro on a list of lists after splitting the input