From 08079e08dd9ffaa6b77ea3ce70aa96da7eb1df26 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 7 Apr 2020 11:53:58 +0100 Subject: Split operations module into submodules --- dhall/src/operations/kind.rs | 97 +++++++ dhall/src/operations/mod.rs | 6 + dhall/src/operations/normalization.rs | 306 ++++++++++++++++++++ dhall/src/operations/typecheck.rs | 510 ++++++++++++++++++++++++++++++++++ 4 files changed, 919 insertions(+) create mode 100644 dhall/src/operations/kind.rs create mode 100644 dhall/src/operations/mod.rs create mode 100644 dhall/src/operations/normalization.rs create mode 100644 dhall/src/operations/typecheck.rs (limited to 'dhall/src/operations') diff --git a/dhall/src/operations/kind.rs b/dhall/src/operations/kind.rs new file mode 100644 index 0000000..5415637 --- /dev/null +++ b/dhall/src/operations/kind.rs @@ -0,0 +1,97 @@ +use std::collections::BTreeSet; + +use crate::syntax::{trivial_result, Label}; + +// Definition order must match precedence order for +// pretty-printing to work correctly +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum BinOp { + /// `x ? y` + ImportAlt, + /// `x || y` + BoolOr, + /// `x + y` + NaturalPlus, + /// `x ++ y` + TextAppend, + /// `x # y` + ListAppend, + /// `x && y` + BoolAnd, + /// `x ∧ y` + RecursiveRecordMerge, + /// `x ⫽ y` + RightBiasedRecordMerge, + /// `x ⩓ y` + RecursiveRecordTypeMerge, + /// `x * y` + NaturalTimes, + /// `x == y` + BoolEQ, + /// `x != y` + BoolNE, + /// x === y + Equivalence, +} + +/// Operations +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum OpKind { + /// `f a` + App(SubExpr, SubExpr), + /// Binary operations + BinOp(BinOp, SubExpr, SubExpr), + /// `if x then y else z` + BoolIf(SubExpr, SubExpr, SubExpr), + /// `merge x y : t` + Merge(SubExpr, SubExpr, Option), + /// `toMap x : t` + ToMap(SubExpr, Option), + /// `e.x` + Field(SubExpr, Label), + /// `e.{ x, y, z }` + Projection(SubExpr, BTreeSet