summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
Diffstat (limited to 'dhall')
-rw-r--r--dhall/src/core/value.rs13
-rw-r--r--dhall/src/core/valuef.rs15
-rw-r--r--dhall/src/phase/mod.rs6
3 files changed, 10 insertions, 24 deletions
diff --git a/dhall/src/core/value.rs b/dhall/src/core/value.rs
index 24e2803..e1623a8 100644
--- a/dhall/src/core/value.rs
+++ b/dhall/src/core/value.rs
@@ -12,7 +12,7 @@ use crate::phase::typecheck::{builtin_to_value, const_to_value};
use crate::phase::{NormalizedSubExpr, Typed};
#[derive(Debug, Clone, Copy)]
-pub enum Form {
+pub(crate) enum Form {
/// No constraints; expression may not be normalized at all.
Unevaled,
/// Weak Head Normal Form, i.e. normalized up to the first constructor, but subexpressions may
@@ -41,13 +41,13 @@ struct ValueInternal {
/// sharing computation automatically. Uses a RefCell to share computation.
/// Can optionally store a type from typechecking to preserve type information.
#[derive(Clone)]
-pub struct Value(Rc<RefCell<ValueInternal>>);
+pub(crate) struct Value(Rc<RefCell<ValueInternal>>);
/// When a function needs to return either a freshly created ValueF or an existing Value, but
/// doesn't want to convert both to the same thing, either to avoid unnecessary allocations or to
/// avoid loss of typ information.
#[derive(Debug, Clone)]
-pub enum VoVF {
+pub(crate) enum VoVF {
Value(Value),
ValueF { val: ValueF, form: Form },
}
@@ -111,10 +111,7 @@ impl Value {
pub(crate) fn from_const(c: Const) -> Self {
const_to_value(c)
}
- pub fn const_type() -> Self {
- Value::from_const(Const::Type)
- }
- pub fn from_builtin(b: Builtin) -> Self {
+ pub(crate) fn from_builtin(b: Builtin) -> Self {
builtin_to_value(b)
}
@@ -234,7 +231,7 @@ impl Value {
}
impl VoVF {
- pub fn into_whnf(self) -> ValueF {
+ pub(crate) fn into_whnf(self) -> ValueF {
match self {
VoVF::Value(v) => v.to_whnf(),
VoVF::ValueF {
diff --git a/dhall/src/core/valuef.rs b/dhall/src/core/valuef.rs
index 316238c..42606a9 100644
--- a/dhall/src/core/valuef.rs
+++ b/dhall/src/core/valuef.rs
@@ -15,7 +15,7 @@ use crate::phase::{Normalized, NormalizedSubExpr};
/// alpha-equivalence (renaming of bound variables) and beta-equivalence (normalization). It will
/// recursively normalize as needed.
#[derive(Debug, Clone, PartialEq, Eq)]
-pub enum ValueF {
+pub(crate) enum ValueF {
/// Closures
Lam(AlphaLabel, Value, Value),
Pi(AlphaLabel, Value, Value),
@@ -53,12 +53,6 @@ impl ValueF {
pub(crate) fn into_value_with_type(self, t: Value) -> Value {
Value::from_valuef_and_type(self, t)
}
- pub(crate) fn into_vovf_unevaled(self) -> VoVF {
- VoVF::ValueF {
- val: self,
- form: Form::Unevaled,
- }
- }
pub(crate) fn into_vovf_whnf(self) -> VoVF {
VoVF::ValueF {
val: self,
@@ -265,12 +259,7 @@ impl ValueF {
}
}
- /// Apply to a value
- pub fn app(self, v: Value) -> VoVF {
- self.into_vovf_unevaled().app(v)
- }
-
- pub fn from_builtin(b: Builtin) -> ValueF {
+ pub(crate) fn from_builtin(b: Builtin) -> ValueF {
ValueF::AppliedBuiltin(b, vec![])
}
}
diff --git a/dhall/src/phase/mod.rs b/dhall/src/phase/mod.rs
index b5b7b64..ecf04e9 100644
--- a/dhall/src/phase/mod.rs
+++ b/dhall/src/phase/mod.rs
@@ -92,13 +92,13 @@ impl Typed {
pub(crate) fn from_const(c: Const) -> Self {
Typed(Value::from_const(c))
}
- pub fn from_valuef_and_type(v: ValueF, t: Typed) -> Self {
+ pub(crate) fn from_valuef_and_type(v: ValueF, t: Typed) -> Self {
Typed(Value::from_valuef_and_type(v, t.into_value()))
}
pub(crate) fn from_value(th: Value) -> Self {
Typed(th)
}
- pub fn const_type() -> Self {
+ pub(crate) fn const_type() -> Self {
Typed::from_const(Const::Type)
}
@@ -108,7 +108,7 @@ impl Typed {
pub(crate) fn to_expr_alpha(&self) -> NormalizedSubExpr {
self.0.to_expr_alpha()
}
- pub fn to_value(&self) -> Value {
+ pub(crate) fn to_value(&self) -> Value {
self.0.clone()
}
pub(crate) fn into_value(self) -> Value {