summaryrefslogtreecommitdiff
path: root/dhall/src/semantics/nze
diff options
context:
space:
mode:
Diffstat (limited to 'dhall/src/semantics/nze')
-rw-r--r--dhall/src/semantics/nze/env.rs6
-rw-r--r--dhall/src/semantics/nze/mod.rs8
-rw-r--r--dhall/src/semantics/nze/nir.rs42
-rw-r--r--dhall/src/semantics/nze/normalize.rs10
-rw-r--r--dhall/src/semantics/nze/var.rs4
5 files changed, 35 insertions, 35 deletions
diff --git a/dhall/src/semantics/nze/env.rs b/dhall/src/semantics/nze/env.rs
index ef2bee6..ec99dbe 100644
--- a/dhall/src/semantics/nze/env.rs
+++ b/dhall/src/semantics/nze/env.rs
@@ -1,7 +1,7 @@
use crate::semantics::{AlphaVar, Nir, NirKind};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub(crate) enum NzVar {
+pub enum NzVar {
/// Reverse-debruijn index: counts number of binders from the bottom of the stack.
Bound(usize),
/// Fake fresh variable generated for expression equality checking.
@@ -17,11 +17,11 @@ enum EnvItem<Type> {
}
#[derive(Debug, Clone)]
-pub(crate) struct ValEnv<Type> {
+pub struct ValEnv<Type> {
items: Vec<EnvItem<Type>>,
}
-pub(crate) type NzEnv = ValEnv<()>;
+pub type NzEnv = ValEnv<()>;
impl NzVar {
pub fn new(idx: usize) -> Self {
diff --git a/dhall/src/semantics/nze/mod.rs b/dhall/src/semantics/nze/mod.rs
index 2648339..23022e0 100644
--- a/dhall/src/semantics/nze/mod.rs
+++ b/dhall/src/semantics/nze/mod.rs
@@ -3,7 +3,7 @@ pub mod lazy;
pub mod nir;
pub mod normalize;
pub mod var;
-pub(crate) use env::*;
-pub(crate) use nir::*;
-pub(crate) use normalize::*;
-pub(crate) use var::*;
+pub use env::*;
+pub use nir::*;
+pub use normalize::*;
+pub use var::*;
diff --git a/dhall/src/semantics/nze/nir.rs b/dhall/src/semantics/nze/nir.rs
index 5fccbf1..e0d227e 100644
--- a/dhall/src/semantics/nze/nir.rs
+++ b/dhall/src/semantics/nze/nir.rs
@@ -19,7 +19,7 @@ use crate::ToExprOptions;
/// normalize as needed.
/// Stands for "Normalized intermediate representation"
#[derive(Clone)]
-pub(crate) struct Nir(Rc<NirInternal>);
+pub struct Nir(Rc<NirInternal>);
#[derive(Debug)]
struct NirInternal {
@@ -28,7 +28,7 @@ struct NirInternal {
/// An unevaluated subexpression
#[derive(Debug, Clone)]
-pub(crate) enum Thunk {
+pub enum Thunk {
/// A completely unnormalized expression.
Thunk { env: NzEnv, body: Hir },
/// A partially normalized expression that may need to go through `normalize_one_layer`.
@@ -37,7 +37,7 @@ pub(crate) enum Thunk {
/// An unevaluated subexpression that takes an argument.
#[derive(Debug, Clone)]
-pub(crate) enum Closure {
+pub enum Closure {
/// Normal closure
Closure { env: NzEnv, body: Hir },
/// Closure that ignores the argument passed
@@ -48,7 +48,7 @@ pub(crate) enum Closure {
// Invariant: this must not contain interpolations that are themselves TextLits, and contiguous
// text values must be merged.
#[derive(Debug, Clone, PartialEq, Eq)]
-pub(crate) struct TextLit(Vec<InterpolatedTextContents<Nir>>);
+pub struct TextLit(Vec<InterpolatedTextContents<Nir>>);
/// This represents a value in Weak Head Normal Form (WHNF). This means that the value is
/// normalized up to the first constructor, but subexpressions may not be fully normalized.
@@ -58,7 +58,7 @@ pub(crate) struct TextLit(Vec<InterpolatedTextContents<Nir>>);
/// In particular, this means that once we get a `NirKind`, it can be considered immutable, and
/// we only need to recursively normalize its sub-`Nir`s to get to the NF.
#[derive(Debug, Clone, PartialEq, Eq)]
-pub(crate) enum NirKind {
+pub enum NirKind {
/// Closures
LamClosure {
binder: Binder,
@@ -97,34 +97,34 @@ pub(crate) enum NirKind {
impl Nir {
/// Construct a Nir from a completely unnormalized expression.
- pub(crate) fn new_thunk(env: NzEnv, hir: Hir) -> Nir {
+ pub fn new_thunk(env: NzEnv, hir: Hir) -> Nir {
NirInternal::from_thunk(Thunk::new(env, hir)).into_nir()
}
/// Construct a Nir from a partially normalized expression that's not in WHNF.
- pub(crate) fn from_partial_expr(e: ExprKind<Nir>) -> Nir {
+ pub fn from_partial_expr(e: ExprKind<Nir>) -> Nir {
// TODO: env
let env = NzEnv::new();
NirInternal::from_thunk(Thunk::from_partial_expr(env, e)).into_nir()
}
/// Make a Nir from a NirKind
- pub(crate) fn from_kind(v: NirKind) -> Nir {
+ pub fn from_kind(v: NirKind) -> Nir {
NirInternal::from_whnf(v).into_nir()
}
- pub(crate) fn from_const(c: Const) -> Self {
+ pub fn from_const(c: Const) -> Self {
let v = NirKind::Const(c);
NirInternal::from_whnf(v).into_nir()
}
- pub(crate) fn from_builtin(b: Builtin) -> Self {
+ pub fn from_builtin(b: Builtin) -> Self {
Self::from_builtin_env(b, &NzEnv::new())
}
- pub(crate) fn from_builtin_env(b: Builtin, env: &NzEnv) -> Self {
+ pub fn from_builtin_env(b: Builtin, env: &NzEnv) -> Self {
Nir::from_kind(NirKind::from_builtin_env(b, env.clone()))
}
- pub(crate) fn from_text(txt: impl ToString) -> Self {
+ pub fn from_text(txt: impl ToString) -> Self {
Nir::from_kind(NirKind::TextLit(TextLit::from_text(txt.to_string())))
}
- pub(crate) fn as_const(&self) -> Option<Const> {
+ pub fn as_const(&self) -> Option<Const> {
match &*self.kind() {
NirKind::Const(c) => Some(*c),
_ => None,
@@ -132,22 +132,22 @@ impl Nir {
}
/// This is what you want if you want to pattern-match on the value.
- pub(crate) fn kind(&self) -> &NirKind {
+ pub fn kind(&self) -> &NirKind {
self.0.kind()
}
- pub(crate) fn to_type(&self, u: impl Into<Universe>) -> Type {
+ pub fn to_type(&self, u: impl Into<Universe>) -> Type {
Type::new(self.clone(), u.into())
}
/// Converts a value back to the corresponding AST expression.
- pub(crate) fn to_expr(&self, opts: ToExprOptions) -> Expr {
+ pub fn to_expr(&self, opts: ToExprOptions) -> Expr {
self.to_hir_noenv().to_expr(opts)
}
- pub(crate) fn to_expr_tyenv(&self, tyenv: &TyEnv) -> Expr {
+ pub fn to_expr_tyenv(&self, tyenv: &TyEnv) -> Expr {
self.to_hir(tyenv.as_varenv()).to_expr_tyenv(tyenv)
}
- pub(crate) fn app(&self, v: Nir) -> Nir {
+ pub fn app(&self, v: Nir) -> Nir {
Nir::from_kind(apply_any(self.clone(), v))
}
@@ -286,14 +286,14 @@ impl NirInternal {
}
impl NirKind {
- pub(crate) fn into_nir(self) -> Nir {
+ pub fn into_nir(self) -> Nir {
Nir::from_kind(self)
}
- pub(crate) fn from_builtin(b: Builtin) -> NirKind {
+ pub fn from_builtin(b: Builtin) -> NirKind {
NirKind::from_builtin_env(b, NzEnv::new())
}
- pub(crate) fn from_builtin_env(b: Builtin, env: NzEnv) -> NirKind {
+ pub fn from_builtin_env(b: Builtin, env: NzEnv) -> NirKind {
BuiltinClosure::new(b, env)
}
}
diff --git a/dhall/src/semantics/nze/normalize.rs b/dhall/src/semantics/nze/normalize.rs
index 46d8fb5..570e106 100644
--- a/dhall/src/semantics/nze/normalize.rs
+++ b/dhall/src/semantics/nze/normalize.rs
@@ -5,7 +5,7 @@ use crate::semantics::NzEnv;
use crate::semantics::{Binder, Closure, Hir, HirKind, Nir, NirKind, TextLit};
use crate::syntax::{BinOp, ExprKind, InterpolatedTextContents, NumKind};
-pub(crate) fn apply_any(f: Nir, a: Nir) -> NirKind {
+pub fn apply_any(f: Nir, a: Nir) -> NirKind {
match f.kind() {
NirKind::LamClosure { closure, .. } => closure.apply(a).kind().clone(),
NirKind::AppliedBuiltin(closure) => closure.apply(a),
@@ -16,7 +16,7 @@ pub(crate) fn apply_any(f: Nir, a: Nir) -> NirKind {
}
}
-pub(crate) fn squash_textlit(
+pub fn squash_textlit(
elts: impl Iterator<Item = InterpolatedTextContents<Nir>>,
) -> Vec<InterpolatedTextContents<Nir>> {
use std::mem::replace;
@@ -54,7 +54,7 @@ pub(crate) fn squash_textlit(
ret
}
-pub(crate) fn merge_maps<K, V, F>(
+pub fn merge_maps<K, V, F>(
map1: &HashMap<K, V>,
map2: &HashMap<K, V>,
mut f: F,
@@ -207,7 +207,7 @@ fn apply_binop<'a>(o: BinOp, x: &'a Nir, y: &'a Nir) -> Option<Ret<'a>> {
}
#[allow(clippy::cognitive_complexity)]
-pub(crate) fn normalize_one_layer(expr: ExprKind<Nir>, env: &NzEnv) -> NirKind {
+pub fn normalize_one_layer(expr: ExprKind<Nir>, env: &NzEnv) -> NirKind {
use NirKind::{
EmptyListLit, EmptyOptionalLit, NEListLit, NEOptionalLit, Num,
PartialExpr, RecordLit, RecordType, UnionConstructor, UnionLit,
@@ -464,7 +464,7 @@ pub(crate) fn normalize_one_layer(expr: ExprKind<Nir>, env: &NzEnv) -> NirKind {
}
/// Normalize Hir into WHNF
-pub(crate) fn normalize_hir_whnf(env: &NzEnv, hir: &Hir) -> NirKind {
+pub fn normalize_hir_whnf(env: &NzEnv, hir: &Hir) -> NirKind {
match hir.kind() {
HirKind::Var(var) => env.lookup_val(*var),
HirKind::Import(hir, _) => normalize_hir_whnf(env, hir),
diff --git a/dhall/src/semantics/nze/var.rs b/dhall/src/semantics/nze/var.rs
index 413c759..302dbb7 100644
--- a/dhall/src/semantics/nze/var.rs
+++ b/dhall/src/semantics/nze/var.rs
@@ -8,10 +8,10 @@ pub struct Binder {
}
impl Binder {
- pub(crate) fn new(name: Label) -> Self {
+ pub fn new(name: Label) -> Self {
Binder { name }
}
- pub(crate) fn to_label(&self) -> Label {
+ pub fn to_label(&self) -> Label {
self.clone().into()
}
}