summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dhall/src/api/serde.rs2
-rw-r--r--dhall/src/core/context.rs34
-rw-r--r--dhall/src/core/thunk.rs48
-rw-r--r--dhall/src/core/value.rs23
-rw-r--r--dhall/src/core/var.rs16
-rw-r--r--dhall/src/phase/mod.rs64
-rw-r--r--dhall/src/phase/normalize.rs17
-rw-r--r--dhall/src/phase/parse.rs6
-rw-r--r--dhall/src/phase/resolve.rs6
-rw-r--r--dhall/src/phase/typecheck.rs15
10 files changed, 106 insertions, 125 deletions
diff --git a/dhall/src/api/serde.rs b/dhall/src/api/serde.rs
index 7be77c0..e1c8eef 100644
--- a/dhall/src/api/serde.rs
+++ b/dhall/src/api/serde.rs
@@ -1,6 +1,6 @@
use crate::api::de::{Deserialize, Value};
use crate::error::{Error, Result};
-use dhall_syntax::{SubExpr,ExprF, X};
+use dhall_syntax::{ExprF, SubExpr, X};
use std::borrow::Cow;
impl<'a, T> Deserialize for T
diff --git a/dhall/src/core/context.rs b/dhall/src/core/context.rs
index 328bfdc..62affcf 100644
--- a/dhall/src/core/context.rs
+++ b/dhall/src/core/context.rs
@@ -10,25 +10,25 @@ use crate::error::TypeError;
use crate::phase::{Type, Typed};
#[derive(Debug, Clone)]
-pub(crate) enum CtxItem<T> {
+pub enum CtxItem<T> {
Kept(AlphaVar, T),
Replaced(Thunk, T),
}
#[derive(Debug, Clone)]
-pub(crate) struct Context<T>(Rc<Vec<(Label, CtxItem<T>)>>);
+pub struct Context<T>(Rc<Vec<(Label, CtxItem<T>)>>);
#[derive(Debug, Clone)]
-pub(crate) struct NormalizationContext(Context<()>);
+pub struct NormalizationContext(Context<()>);
#[derive(Debug, Clone)]
-pub(crate) struct TypecheckContext(Context<Type>);
+pub struct TypecheckContext(Context<Type>);
impl<T> Context<T> {
- pub(crate) fn new() -> Self {
+ pub fn new() -> Self {
Context(Rc::new(Vec::new()))
}
- pub(crate) fn insert_kept(&self, x: &Label, t: T) -> Self
+ pub fn insert_kept(&self, x: &Label, t: T) -> Self
where
T: Shift + Clone,
{
@@ -36,7 +36,7 @@ impl<T> Context<T> {
vec.push((x.clone(), CtxItem::Kept(x.into(), t.under_binder(x))));
Context(Rc::new(vec))
}
- pub(crate) fn insert_replaced(&self, x: &Label, th: Thunk, t: T) -> Self
+ pub fn insert_replaced(&self, x: &Label, th: Thunk, t: T) -> Self
where
T: Clone,
{
@@ -44,7 +44,7 @@ impl<T> Context<T> {
vec.push((x.clone(), CtxItem::Replaced(th, t)));
Context(Rc::new(vec))
}
- pub(crate) fn lookup(&self, var: &V<Label>) -> Result<CtxItem<T>, V<Label>>
+ pub fn lookup(&self, var: &V<Label>) -> Result<CtxItem<T>, V<Label>>
where
T: Clone + Shift,
{
@@ -109,13 +109,13 @@ impl<T> Context<T> {
}
impl NormalizationContext {
- pub(crate) fn new() -> Self {
+ pub fn new() -> Self {
NormalizationContext(Context::new())
}
- pub(crate) fn skip(&self, x: &Label) -> Self {
+ pub fn skip(&self, x: &Label) -> Self {
NormalizationContext(self.0.insert_kept(x, ()))
}
- pub(crate) fn lookup(&self, var: &V<Label>) -> Value {
+ pub fn lookup(&self, var: &V<Label>) -> Value {
match self.0.lookup(var) {
Ok(CtxItem::Replaced(t, ())) => t.to_value(),
Ok(CtxItem::Kept(newvar, ())) => Value::Var(newvar.clone()),
@@ -125,24 +125,20 @@ impl NormalizationContext {
}
impl TypecheckContext {
- pub(crate) fn new() -> Self {
+ pub fn new() -> Self {
TypecheckContext(Context::new())
}
- pub(crate) fn insert_type(&self, x: &Label, t: Type) -> Self {
+ pub fn insert_type(&self, x: &Label, t: Type) -> Self {
TypecheckContext(self.0.insert_kept(x, t))
}
- pub(crate) fn insert_value(
- &self,
- x: &Label,
- e: Typed,
- ) -> Result<Self, TypeError> {
+ pub fn insert_value(&self, x: &Label, e: Typed) -> Result<Self, TypeError> {
Ok(TypecheckContext(self.0.insert_replaced(
x,
e.to_thunk(),
e.get_type()?.into_owned(),
)))
}
- pub(crate) fn lookup(&self, var: &V<Label>) -> Option<Typed> {
+ pub fn lookup(&self, var: &V<Label>) -> Option<Typed> {
match self.0.lookup(var) {
Ok(CtxItem::Kept(newvar, t)) => Some(Typed::from_thunk_and_type(
Thunk::from_value(Value::Var(newvar.clone())),
diff --git a/dhall/src/core/thunk.rs b/dhall/src/core/thunk.rs
index 2d4c34d..0e4f2d5 100644
--- a/dhall/src/core/thunk.rs
+++ b/dhall/src/core/thunk.rs
@@ -42,7 +42,7 @@ pub struct Thunk(Rc<RefCell<ThunkInternal>>);
/// A thunk in type position. Can optionally store a Type from the typechecking phase to preserve
/// type information through the normalization phase.
#[derive(Debug, Clone)]
-pub(crate) struct TypeThunk(Typed);
+pub struct TypeThunk(Typed);
impl ThunkInternal {
fn into_thunk(self) -> Thunk {
@@ -103,25 +103,25 @@ impl ThunkInternal {
}
impl Thunk {
- pub(crate) fn new(ctx: NormalizationContext, e: InputSubExpr) -> Thunk {
+ pub fn new(ctx: NormalizationContext, e: InputSubExpr) -> Thunk {
ThunkInternal::Unnormalized(ctx, e).into_thunk()
}
- pub(crate) fn from_value(v: Value) -> Thunk {
+ pub fn from_value(v: Value) -> Thunk {
ThunkInternal::Value(WHNF, v).into_thunk()
}
- pub(crate) fn from_normalized_expr(e: OutputSubExpr) -> Thunk {
+ pub fn from_normalized_expr(e: OutputSubExpr) -> Thunk {
Thunk::new(NormalizationContext::new(), e.absurd())
}
- pub(crate) fn from_partial_expr(e: ExprF<Thunk, X>) -> Thunk {
+ pub fn from_partial_expr(e: ExprF<Thunk, X>) -> Thunk {
ThunkInternal::PartialExpr(e).into_thunk()
}
// Normalizes contents to normal form; faster than `normalize_nf` if
// no one else shares this thunk
- pub(crate) fn normalize_mut(&mut self) {
+ pub fn normalize_mut(&mut self) {
match Rc::get_mut(&mut self.0) {
// Mutate directly if sole owner
Some(refcell) => RefCell::get_mut(refcell).normalize_nf(),
@@ -159,75 +159,69 @@ impl Thunk {
// WARNING: avoid normalizing any thunk while holding on to this ref
// or you could run into BorrowMut panics
- pub(crate) fn normalize_nf(&self) -> Ref<Value> {
+ pub fn normalize_nf(&self) -> Ref<Value> {
self.do_normalize_nf();
Ref::map(self.0.borrow(), ThunkInternal::as_nf)
}
// WARNING: avoid normalizing any thunk while holding on to this ref
// or you could run into BorrowMut panics
- pub(crate) fn as_value(&self) -> Ref<Value> {
+ pub fn as_value(&self) -> Ref<Value> {
self.do_normalize_whnf();
Ref::map(self.0.borrow(), ThunkInternal::as_whnf)
}
- pub(crate) fn to_value(&self) -> Value {
+ pub fn to_value(&self) -> Value {
self.as_value().clone()
}
- pub(crate) fn normalize_to_expr_maybe_alpha(
- &self,
- alpha: bool,
- ) -> OutputSubExpr {
+ pub fn normalize_to_expr_maybe_alpha(&self, alpha: bool) -> OutputSubExpr {
self.normalize_nf().normalize_to_expr_maybe_alpha(alpha)
}
- pub(crate) fn app_val(&self, val: Value) -> Value {
+ pub fn app_val(&self, val: Value) -> Value {
self.app_thunk(val.into_thunk())
}
- pub(crate) fn app_thunk(&self, th: Thunk) -> Value {
+ pub fn app_thunk(&self, th: Thunk) -> Value {
apply_any(self.clone(), th)
}
}
impl TypeThunk {
- pub(crate) fn from_value(v: Value) -> TypeThunk {
+ pub fn from_value(v: Value) -> TypeThunk {
TypeThunk::from_thunk(Thunk::from_value(v))
}
- pub(crate) fn from_thunk(th: Thunk) -> TypeThunk {
+ pub fn from_thunk(th: Thunk) -> TypeThunk {
TypeThunk(Typed::from_thunk_untyped(th))
}
- pub(crate) fn from_type(t: Type) -> TypeThunk {
+ pub fn from_type(t: Type) -> TypeThunk {
TypeThunk(t.to_typed())
}
- pub(crate) fn normalize_mut(&mut self) {
+ pub fn normalize_mut(&mut self) {
self.0.normalize_mut()
}
- pub(crate) fn normalize_nf(&self) -> Value {
+ pub fn normalize_nf(&self) -> Value {
self.0.to_value().normalize()
}
- pub(crate) fn to_value(&self) -> Value {
+ pub fn to_value(&self) -> Value {
self.0.to_value()
}
- pub(crate) fn to_thunk(&self) -> Thunk {
+ pub fn to_thunk(&self) -> Thunk {
self.0.to_thunk()
}
- pub(crate) fn to_type(&self) -> Type {
+ pub fn to_type(&self) -> Type {
self.0.to_type()
}
- pub(crate) fn normalize_to_expr_maybe_alpha(
- &self,
- alpha: bool,
- ) -> OutputSubExpr {
+ pub fn normalize_to_expr_maybe_alpha(&self, alpha: bool) -> OutputSubExpr {
self.normalize_nf().normalize_to_expr_maybe_alpha(alpha)
}
}
diff --git a/dhall/src/core/value.rs b/dhall/src/core/value.rs
index 799cfac..cff599b 100644
--- a/dhall/src/core/value.rs
+++ b/dhall/src/core/value.rs
@@ -25,7 +25,7 @@ use crate::phase::Typed;
/// Equality is up to alpha-equivalence (renaming of bound variables) and beta-equivalence
/// (normalization). Equality will normalize only as needed.
#[derive(Debug, Clone, PartialEq, Eq)]
-pub(crate) enum Value {
+pub enum Value {
/// Closures
Lam(AlphaLabel, TypeThunk, Thunk),
Pi(AlphaLabel, TypeThunk, TypeThunk),
@@ -62,20 +62,17 @@ pub(crate) enum Value {
}
impl Value {
- pub(crate) fn into_thunk(self) -> Thunk {
+ pub fn into_thunk(self) -> Thunk {
Thunk::from_value(self)
}
/// Convert the value to a fully normalized syntactic expression
- pub(crate) fn normalize_to_expr(&self) -> OutputSubExpr {
+ pub fn normalize_to_expr(&self) -> OutputSubExpr {
self.normalize_to_expr_maybe_alpha(false)
}
/// Convert the value to a fully normalized syntactic expression. Also alpha-normalize
/// if alpha is `true`
- pub(crate) fn normalize_to_expr_maybe_alpha(
- &self,
- alpha: bool,
- ) -> OutputSubExpr {
+ pub fn normalize_to_expr_maybe_alpha(&self, alpha: bool) -> OutputSubExpr {
match self {
Value::Lam(x, t, e) => rc(ExprF::Lam(
x.to_label_maybe_alpha(alpha),
@@ -213,13 +210,13 @@ impl Value {
}
// Deprecated
- pub(crate) fn normalize(&self) -> Value {
+ pub fn normalize(&self) -> Value {
let mut v = self.clone();
v.normalize_mut();
v
}
- pub(crate) fn normalize_mut(&mut self) {
+ pub fn normalize_mut(&mut self) {
match self {
Value::NaturalSuccClosure
| Value::Var(_)
@@ -302,21 +299,21 @@ impl Value {
}
/// Apply to a value
- pub(crate) fn app(self, val: Value) -> Value {
+ pub fn app(self, val: Value) -> Value {
self.app_val(val)
}
/// Apply to a value
- pub(crate) fn app_val(self, val: Value) -> Value {
+ pub fn app_val(self, val: Value) -> Value {
self.app_thunk(val.into_thunk())
}
/// Apply to a thunk
- pub(crate) fn app_thunk(self, th: Thunk) -> Value {
+ pub fn app_thunk(self, th: Thunk) -> Value {
Thunk::from_value(self).app_thunk(th)
}
- pub(crate) fn from_builtin(b: Builtin) -> Value {
+ pub fn from_builtin(b: Builtin) -> Value {
Value::AppliedBuiltin(b, vec![])
}
}
diff --git a/dhall/src/core/var.rs b/dhall/src/core/var.rs
index ea7e55f..e474e44 100644
--- a/dhall/src/core/var.rs
+++ b/dhall/src/core/var.rs
@@ -6,7 +6,7 @@ use dhall_syntax::{Label, V};
/// that corresponds to the alpha-normalized version of the first one.
/// Equality is up to alpha-equivalence.
#[derive(Debug, Clone, Eq)]
-pub(crate) struct AlphaVar {
+pub struct AlphaVar {
normal: V<Label>,
alpha: Option<V<()>>,
}
@@ -14,9 +14,9 @@ pub(crate) struct AlphaVar {
// Exactly like a Label, but equality returns always true.
// This is so that Value equality is exactly alpha-equivalence.
#[derive(Debug, Clone, Eq)]
-pub(crate) struct AlphaLabel(Label);
+pub struct AlphaLabel(Label);
-pub(crate) trait Shift: Sized {
+pub trait Shift: Sized {
// Shift an expression to move it around binders without changing the meaning of its free
// variables. Shift by 1 to move an expression under a binder. Shift by -1 to extract an
// expression from under a binder, if the expression does not refer to that bound variable.
@@ -50,18 +50,18 @@ pub(crate) trait Shift: Sized {
}
}
-pub(crate) trait Subst<T> {
+pub trait Subst<T> {
fn subst_shift(&self, var: &AlphaVar, val: &T) -> Self;
}
impl AlphaVar {
- pub(crate) fn to_var(&self, alpha: bool) -> V<Label> {
+ pub fn to_var(&self, alpha: bool) -> V<Label> {
match (alpha, &self.alpha) {
(true, Some(x)) => V("_".into(), x.1),
_ => self.normal.clone(),
}
}
- pub(crate) fn from_var(normal: V<Label>) -> Self {
+ pub fn from_var(normal: V<Label>) -> Self {
AlphaVar {
normal,
alpha: None,
@@ -70,14 +70,14 @@ impl AlphaVar {
}
impl AlphaLabel {
- pub(crate) fn to_label_maybe_alpha(&self, alpha: bool) -> Label {
+ pub fn to_label_maybe_alpha(&self, alpha: bool) -> Label {
if alpha {
"_".into()
} else {
self.to_label()
}
}
- pub(crate) fn to_label(&self) -> Label {
+ pub fn to_label(&self) -> Label {
self.clone().into()
}
}
diff --git a/dhall/src/phase/mod.rs b/dhall/src/phase/mod.rs
index d7cec67..abf4fe7 100644
--- a/dhall/src/phase/mod.rs
+++ b/dhall/src/phase/mod.rs
@@ -19,20 +19,20 @@ pub(crate) mod parse;
pub(crate) mod resolve;
pub(crate) mod typecheck;
-pub(crate) type ParsedSubExpr = SubExpr<Span, Import>;
-pub(crate) type ResolvedSubExpr = SubExpr<Span, Normalized>;
-pub(crate) type NormalizedSubExpr = SubExpr<X, X>;
+pub type ParsedSubExpr = SubExpr<Span, Import>;
+pub type ResolvedSubExpr = SubExpr<Span, Normalized>;
+pub type NormalizedSubExpr = SubExpr<X, X>;
#[derive(Debug, Clone)]
-pub(crate) struct Parsed(pub(crate) ParsedSubExpr, pub(crate) ImportRoot);
+pub struct Parsed(ParsedSubExpr, ImportRoot);
/// An expression where all imports have been resolved
#[derive(Debug, Clone)]
-pub(crate) struct Resolved(pub(crate) ResolvedSubExpr);
+pub struct Resolved(ResolvedSubExpr);
/// A typed expression
#[derive(Debug, Clone)]
-pub(crate) enum Typed {
+pub enum Typed {
// Any value, along with (optionally) its type
Untyped(Thunk),
Typed(Thunk, Box<Type>),
@@ -47,10 +47,10 @@ pub(crate) enum Typed {
///
/// Invariant: the contained Typed expression must be in normal form,
#[derive(Debug, Clone)]
-pub(crate) struct Normalized(pub(crate) Typed);
+pub struct Normalized(Typed);
#[derive(Debug, Clone, PartialEq, Eq)]
-pub(crate) struct Type(pub(crate) Typed);
+pub struct Type(Typed);
impl Parsed {
pub fn parse_file(f: &Path) -> Result<Parsed, Error> {
@@ -109,57 +109,57 @@ impl Typed {
Normalized(self)
}
- pub(crate) fn from_thunk_and_type(th: Thunk, t: Type) -> Self {
+ pub fn from_thunk_and_type(th: Thunk, t: Type) -> Self {
Typed::Typed(th, Box::new(t))
}
- pub(crate) fn from_thunk_untyped(th: Thunk) -> Self {
+ pub fn from_thunk_untyped(th: Thunk) -> Self {
Typed::Untyped(th)
}
- pub(crate) fn from_const(c: Const) -> Self {
+ pub fn from_const(c: Const) -> Self {
Typed::Const(c)
}
- pub(crate) fn from_value_untyped(v: Value) -> Self {
+ pub fn from_value_untyped(v: Value) -> Self {
Typed::Untyped(Thunk::from_value(v))
}
- pub(crate) fn from_normalized_expr_untyped(e: NormalizedSubExpr) -> Self {
+ pub fn from_normalized_expr_untyped(e: NormalizedSubExpr) -> Self {
Typed::from_thunk_untyped(Thunk::from_normalized_expr(e))
}
// TODO: Avoid cloning if possible
- pub(crate) fn to_value(&self) -> Value {
+ pub fn to_value(&self) -> Value {
match self {
Typed::Untyped(th) | Typed::Typed(th, _) => th.to_value(),
Typed::Const(c) => Value::Const(*c),
}
}
- pub(crate) fn to_expr(&self) -> NormalizedSubExpr {
+ pub fn to_expr(&self) -> NormalizedSubExpr {
self.to_value().normalize_to_expr()
}
- pub(crate) fn to_expr_alpha(&self) -> NormalizedSubExpr {
+ pub fn to_expr_alpha(&self) -> NormalizedSubExpr {
self.to_value().normalize_to_expr_maybe_alpha(true)
}
- pub(crate) fn to_thunk(&self) -> Thunk {
+ pub fn to_thunk(&self) -> Thunk {
match self {
Typed::Untyped(th) | Typed::Typed(th, _) => th.clone(),
Typed::Const(c) => Thunk::from_value(Value::Const(*c)),
}
}
// Deprecated
- pub(crate) fn to_type(&self) -> Type {
+ pub fn to_type(&self) -> Type {
self.clone().into_type()
}
- pub(crate) fn into_type(self) -> Type {
+ pub fn into_type(self) -> Type {
Type(self)
}
- pub(crate) fn normalize_mut(&mut self) {
+ pub fn normalize_mut(&mut self) {
match self {
Typed::Untyped(th) | Typed::Typed(th, _) => th.normalize_mut(),
Typed::Const(_) => {}
}
}
- pub(crate) fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> {
+ pub fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> {
match self {
Typed::Untyped(_) => Err(TypeError::new(
&TypecheckContext::new(),
@@ -173,46 +173,46 @@ impl Typed {
impl Type {
// Deprecated
- pub(crate) fn to_normalized(&self) -> Normalized {
+ pub fn to_normalized(&self) -> Normalized {
self.0.clone().normalize()
}
- pub(crate) fn to_expr(&self) -> NormalizedSubExpr {
+ pub fn to_expr(&self) -> NormalizedSubExpr {
self.0.to_expr()
}
- pub(crate) fn to_value(&self) -> Value {
+ pub fn to_value(&self) -> Value {
self.0.to_value()
}
- pub(crate) fn to_typed(&self) -> Typed {
+ pub fn to_typed(&self) -> Typed {
self.0.clone()
}
- pub(crate) fn as_const(&self) -> Option<Const> {
+ pub fn as_const(&self) -> Option<Const> {
// TODO: avoid clone
match &self.to_value() {
Value::Const(c) => Some(*c),
_ => None,
}
}
- pub(crate) fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> {
+ pub fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> {
self.0.get_type()
}
- pub(crate) fn from_const(c: Const) -> Self {
+ pub fn from_const(c: Const) -> Self {
Type(Typed::from_const(c))
}
}
impl Normalized {
#[allow(dead_code)]
- pub(crate) fn to_expr_alpha(&self) -> NormalizedSubExpr {
+ pub fn to_expr_alpha(&self) -> NormalizedSubExpr {
self.0.to_expr_alpha()
}
- pub(crate) fn to_value(&self) -> Value {
+ pub fn to_value(&self) -> Value {
self.0.to_value()
}
- pub(crate) fn into_typed(self) -> Typed {
+ pub fn into_typed(self) -> Typed {
self.0
}
- pub(crate) fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> {
+ pub fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> {
self.0.get_type()
}
}
diff --git a/dhall/src/phase/normalize.rs b/dhall/src/phase/normalize.rs
index 64de2a7..2253ae0 100644
--- a/dhall/src/phase/normalize.rs
+++ b/dhall/src/phase/normalize.rs
@@ -11,10 +11,10 @@ use crate::core::value::Value;
use crate::core::var::Subst;
use crate::phase::{NormalizedSubExpr, ResolvedSubExpr, Typed};
-pub(crate) type InputSubExpr = ResolvedSubExpr;
-pub(crate) type OutputSubExpr = NormalizedSubExpr;
+pub type InputSubExpr = ResolvedSubExpr;
+pub type OutputSubExpr = NormalizedSubExpr;
-pub(crate) fn apply_builtin(b: Builtin, args: Vec<Thunk>) -> Value {
+pub fn apply_builtin(b: Builtin, args: Vec<Thunk>) -> Value {
use dhall_syntax::Builtin::*;
use Value::*;
@@ -246,7 +246,7 @@ pub(crate) fn apply_builtin(b: Builtin, args: Vec<Thunk>) -> Value {
}
}
-pub(crate) fn apply_any(f: Thunk, a: Thunk) -> Value {
+pub fn apply_any(f: Thunk, a: Thunk) -> Value {
let fallback = |f: Thunk, a: Thunk| Value::PartialExpr(ExprF::App(f, a));
let f_borrow = f.as_value();
@@ -302,7 +302,7 @@ pub(crate) fn apply_any(f: Thunk, a: Thunk) -> Value {
}
}
-pub(crate) fn squash_textlit(
+pub fn squash_textlit(
elts: impl Iterator<Item = InterpolatedTextContents<Thunk>>,
) -> Vec<InterpolatedTextContents<Thunk>> {
use std::mem::replace;
@@ -345,10 +345,7 @@ pub(crate) fn squash_textlit(
}
/// Reduces the imput expression to a Value. Evaluates as little as possible.
-pub(crate) fn normalize_whnf(
- ctx: NormalizationContext,
- expr: InputSubExpr,
-) -> Value {
+pub fn normalize_whnf(ctx: NormalizationContext, expr: InputSubExpr) -> Value {
match expr.as_ref() {
ExprF::Embed(e) => return e.to_value(),
ExprF::Var(v) => return ctx.lookup(v),
@@ -520,7 +517,7 @@ fn apply_binop<'a>(o: BinOp, x: &'a Thunk, y: &'a Thunk) -> Option<Ret<'a>> {
})
}
-pub(crate) fn normalize_one_layer(expr: ExprF<Thunk, X>) -> Value {
+pub fn normalize_one_layer(expr: ExprF<Thunk, X>) -> Value {
use Ret::{RetExpr, RetThunk, RetThunkRef, RetValue};
use Value::{
BoolLit, DoubleLit, EmptyListLit, EmptyOptionalLit, IntegerLit, Lam,
diff --git a/dhall/src/phase/parse.rs b/dhall/src/phase/parse.rs
index d5cb9f5..765fc09 100644
--- a/dhall/src/phase/parse.rs
+++ b/dhall/src/phase/parse.rs
@@ -8,7 +8,7 @@ use crate::error::Error;
use crate::phase::resolve::ImportRoot;
use crate::phase::Parsed;
-pub(crate) fn parse_file(f: &Path) -> Result<Parsed, Error> {
+pub fn parse_file(f: &Path) -> Result<Parsed, Error> {
let mut buffer = String::new();
File::open(f)?.read_to_string(&mut buffer)?;
let expr = parse_expr(&*buffer)?;
@@ -16,13 +16,13 @@ pub(crate) fn parse_file(f: &Path) -> Result<Parsed, Error> {
Ok(Parsed(expr, root))
}
-pub(crate) fn parse_str(s: &str) -> Result<Parsed, Error> {
+pub fn parse_str(s: &str) -> Result<Parsed, Error> {
let expr = parse_expr(s)?;
let root = ImportRoot::LocalDir(std::env::current_dir()?);
Ok(Parsed(expr, root))
}
-pub(crate) fn parse_binary_file(f: &Path) -> Result<Parsed, Error> {
+pub fn parse_binary_file(f: &Path) -> Result<Parsed, Error> {
let mut buffer = Vec::new();
File::open(f)?.read_to_end(&mut buffer)?;
let expr = crate::phase::binary::decode(&buffer)?;
diff --git a/dhall/src/phase/resolve.rs b/dhall/src/phase/resolve.rs
index 5ab03ac..7e446eb 100644
--- a/dhall/src/phase/resolve.rs
+++ b/dhall/src/phase/resolve.rs
@@ -14,7 +14,7 @@ pub enum ImportRoot {
type ImportCache = HashMap<Import, Normalized>;
-pub(crate) type ImportStack = Vec<Import>;
+pub type ImportStack = Vec<Import>;
fn resolve_import(
import: &Import,
@@ -89,11 +89,11 @@ fn do_resolve_expr(
Ok(Resolved(expr))
}
-pub(crate) fn resolve(e: Parsed) -> Result<Resolved, ImportError> {
+pub fn resolve(e: Parsed) -> Result<Resolved, ImportError> {
do_resolve_expr(e, &mut HashMap::new(), &Vec::new())
}
-pub(crate) fn skip_resolve_expr(
+pub fn skip_resolve_expr(
Parsed(expr, _root): Parsed,
) -> Result<Resolved, ImportError> {
let resolve = |import: &Import| -> Result<Normalized, ImportError> {
diff --git a/dhall/src/phase/typecheck.rs b/dhall/src/phase/typecheck.rs
index 7f988c8..c2d9da3 100644
--- a/dhall/src/phase/typecheck.rs
+++ b/dhall/src/phase/typecheck.rs
@@ -218,7 +218,7 @@ where
eL0.borrow().to_value() == eR0.borrow().to_value()
}
-pub(crate) fn type_of_const(c: Const) -> Result<Type, TypeError> {
+pub fn type_of_const(c: Const) -> Result<Type, TypeError> {
match c {
Const::Type => Ok(Type::from_const(Const::Kind)),
Const::Kind => Ok(Type::from_const(Const::Sort)),
@@ -317,14 +317,14 @@ fn type_of_builtin(b: Builtin) -> Expr<X, X> {
/// Takes an expression that is meant to contain a Type
/// and turn it into a type, typechecking it along the way.
-pub(crate) fn mktype(
+pub fn mktype(
ctx: &TypecheckContext,
e: SubExpr<Span, Normalized>,
) -> Result<Type, TypeError> {
Ok(type_with(ctx, e)?.to_type())
}
-pub(crate) fn builtin_to_type(b: Builtin) -> Result<Type, TypeError> {
+pub fn builtin_to_type(b: Builtin) -> Result<Type, TypeError> {
mktype(&TypecheckContext::new(), SubExpr::from_builtin(b))
}
@@ -777,19 +777,16 @@ fn type_of(e: SubExpr<Span, Normalized>) -> Result<Typed, TypeError> {
Ok(e)
}
-pub(crate) fn typecheck(e: Resolved) -> Result<Typed, TypeError> {
+pub fn typecheck(e: Resolved) -> Result<Typed, TypeError> {
type_of(e.0)
}
-pub(crate) fn typecheck_with(
- e: Resolved,
- ty: &Type,
-) -> Result<Typed, TypeError> {
+pub fn typecheck_with(e: Resolved, ty: &Type) -> Result<Typed, TypeError> {
let expr: SubExpr<_, _> = e.0;
let ty: SubExpr<_, _> = ty.to_expr().absurd();
type_of(expr.rewrap(ExprF::Annot(expr.clone(), ty)))
}
-pub(crate) fn skip_typecheck(e: Resolved) -> Typed {
+pub fn skip_typecheck(e: Resolved) -> Typed {
Typed::from_thunk_untyped(Thunk::new(NormalizationContext::new(), e.0))
}