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.rs | 902 ---------------------------------- dhall/src/operations/kind.rs | 97 ++++ dhall/src/operations/mod.rs | 6 + dhall/src/operations/normalization.rs | 306 ++++++++++++ dhall/src/operations/typecheck.rs | 510 +++++++++++++++++++ 5 files changed, 919 insertions(+), 902 deletions(-) delete mode 100644 dhall/src/operations.rs 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') diff --git a/dhall/src/operations.rs b/dhall/src/operations.rs deleted file mode 100644 index c95159c..0000000 --- a/dhall/src/operations.rs +++ /dev/null @@ -1,902 +0,0 @@ -use itertools::Itertools; -use std::borrow::Cow; -use std::cmp::max; -use std::collections::{BTreeSet, HashMap}; -use std::iter::once; - -use crate::builtins::Builtin; -use crate::error::{ErrorBuilder, TypeError}; -use crate::semantics::{ - merge_maps, mk_span_err, mkerr, ret_kind, ret_op, ret_ref, Binder, Closure, - Hir, HirKind, Nir, NirKind, Ret, TextLit, Tir, TyEnv, Type, -}; -use crate::syntax::{trivial_result, Const, ExprKind, Label, NumKind, Span}; - -// 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