summaryrefslogtreecommitdiff
path: root/dhall/src/semantics/phase
diff options
context:
space:
mode:
authorNadrieril2019-12-27 14:26:40 +0000
committerNadrieril2020-01-17 10:06:00 +0000
commit8edbeadbd0dc06a75ffb8bf3b0a54a62e3acc5fc (patch)
treea7c6f79d1ad8a81e430cac14ebdf66ad92d188f7 /dhall/src/semantics/phase
parent3603fbf9d321602a2df51e7b3f7a69425bd4d304 (diff)
Parameterize ValueKind by its subnodes
Diffstat (limited to '')
-rw-r--r--dhall/src/semantics/phase/mod.rs2
-rw-r--r--dhall/src/semantics/phase/normalize.rs15
2 files changed, 10 insertions, 7 deletions
diff --git a/dhall/src/semantics/phase/mod.rs b/dhall/src/semantics/phase/mod.rs
index 5332eb3..104a1ba 100644
--- a/dhall/src/semantics/phase/mod.rs
+++ b/dhall/src/semantics/phase/mod.rs
@@ -94,7 +94,7 @@ impl Typed {
pub(crate) fn from_const(c: Const) -> Self {
Typed(Value::from_const(c))
}
- pub(crate) fn from_kind_and_type(v: ValueKind, t: Typed) -> Self {
+ pub(crate) fn from_kind_and_type(v: ValueKind<Value>, t: Typed) -> Self {
Typed(Value::from_kind_and_type(v, t.into_value()))
}
pub(crate) fn from_value(th: Value) -> Self {
diff --git a/dhall/src/semantics/phase/normalize.rs b/dhall/src/semantics/phase/normalize.rs
index 0c581fe..7b4b37f 100644
--- a/dhall/src/semantics/phase/normalize.rs
+++ b/dhall/src/semantics/phase/normalize.rs
@@ -68,13 +68,13 @@ pub(crate) fn apply_builtin(
b: Builtin,
args: Vec<Value>,
ty: &Value,
-) -> ValueKind {
+) -> ValueKind<Value> {
use syntax::Builtin::*;
use ValueKind::*;
// Small helper enum
enum Ret<'a> {
- ValueKind(ValueKind),
+ ValueKind(ValueKind<Value>),
Value(Value),
// For applications that can return a function, it's important to keep the remaining
// arguments to apply them to the resulting function.
@@ -365,7 +365,7 @@ pub(crate) fn apply_builtin(
}
}
-pub(crate) fn apply_any(f: Value, a: Value, ty: &Value) -> ValueKind {
+pub(crate) fn apply_any(f: Value, a: Value, ty: &Value) -> ValueKind<Value> {
let f_borrow = f.as_whnf();
match &*f_borrow {
ValueKind::Lam(x, _, e) => {
@@ -456,7 +456,7 @@ where
// Small helper enum to avoid repetition
enum Ret<'a> {
- ValueKind(ValueKind),
+ ValueKind(ValueKind<Value>),
Value(Value),
ValueRef(&'a Value),
Expr(ExprKind<Value, Normalized>),
@@ -589,7 +589,7 @@ fn apply_binop<'a>(
pub(crate) fn normalize_one_layer(
expr: ExprKind<Value, Normalized>,
ty: &Value,
-) -> ValueKind {
+) -> ValueKind<Value> {
use ValueKind::{
AppliedBuiltin, BoolLit, DoubleLit, EmptyListLit, EmptyOptionalLit,
IntegerLit, NEListLit, NEOptionalLit, NaturalLit, RecordLit, TextLit,
@@ -779,7 +779,10 @@ pub(crate) fn normalize_one_layer(
}
/// Normalize a ValueKind into WHNF
-pub(crate) fn normalize_whnf(v: ValueKind, ty: &Value) -> ValueKind {
+pub(crate) fn normalize_whnf(
+ v: ValueKind<Value>,
+ ty: &Value,
+) -> ValueKind<Value> {
match v {
ValueKind::AppliedBuiltin(b, args) => apply_builtin(b, args, ty),
ValueKind::PartialExpr(e) => normalize_one_layer(e, ty),