summaryrefslogtreecommitdiff
path: root/dhall/src
diff options
context:
space:
mode:
authorNadrieril2019-08-16 17:56:19 +0200
committerNadrieril2019-08-16 18:01:46 +0200
commit88ebc0f9d561a2541aad84a3152511a0439db8b4 (patch)
tree73571d5509f8631da63c09ec78acd30862f237f9 /dhall/src
parente8bf879471708ac2cc03df904d14a618daaf2132 (diff)
Reduce api surface of dhall crate
Helps detect unused code
Diffstat (limited to 'dhall/src')
-rw-r--r--dhall/src/core/context.rs8
-rw-r--r--dhall/src/core/thunk.rs56
-rw-r--r--dhall/src/core/value.rs19
-rw-r--r--dhall/src/core/var.rs14
-rw-r--r--dhall/src/phase/binary.rs4
-rw-r--r--dhall/src/phase/mod.rs41
-rw-r--r--dhall/src/phase/normalize.rs14
-rw-r--r--dhall/src/phase/parse.rs8
-rw-r--r--dhall/src/phase/resolve.rs8
-rw-r--r--dhall/src/phase/typecheck.rs12
10 files changed, 86 insertions, 98 deletions
diff --git a/dhall/src/core/context.rs b/dhall/src/core/context.rs
index 8d14415..9230a2e 100644
--- a/dhall/src/core/context.rs
+++ b/dhall/src/core/context.rs
@@ -10,19 +10,19 @@ use crate::error::TypeError;
use crate::phase::{Type, Typed};
#[derive(Debug, Clone)]
-pub enum CtxItem<T> {
+enum CtxItem<T> {
Kept(AlphaVar, T),
Replaced(Thunk, T),
}
#[derive(Debug, Clone)]
-pub struct Context<T>(Rc<Vec<(Label, CtxItem<T>)>>);
+struct Context<T>(Rc<Vec<(Label, CtxItem<T>)>>);
#[derive(Debug, Clone)]
-pub struct NormalizationContext(Context<()>);
+pub(crate) struct NormalizationContext(Context<()>);
#[derive(Debug, Clone)]
-pub struct TypecheckContext(Context<Type>);
+pub(crate) struct TypecheckContext(Context<Type>);
impl<T> Context<T> {
pub fn new() -> Self {
diff --git a/dhall/src/core/thunk.rs b/dhall/src/core/thunk.rs
index 14d8792..54a5442 100644
--- a/dhall/src/core/thunk.rs
+++ b/dhall/src/core/thunk.rs
@@ -115,21 +115,21 @@ impl ThunkInternal {
}
impl Thunk {
- pub fn new(ctx: NormalizationContext, e: InputSubExpr) -> Thunk {
+ pub(crate) fn new(ctx: NormalizationContext, e: InputSubExpr) -> Thunk {
ThunkInternal::Unnormalized(ctx, e).into_thunk()
}
- pub fn from_value(v: Value) -> Thunk {
+ pub(crate) fn from_value(v: Value) -> Thunk {
ThunkInternal::Value(WHNF, v).into_thunk()
}
- pub fn from_partial_expr(e: ExprF<Thunk, Normalized>) -> Thunk {
+ pub(crate) fn from_partial_expr(e: ExprF<Thunk, Normalized>) -> Thunk {
ThunkInternal::PartialExpr(e).into_thunk()
}
// Normalizes contents to normal form; faster than `normalize_nf` if
// no one else shares this thunk
- pub fn normalize_mut(&mut self) {
+ pub(crate) 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(),
@@ -167,37 +167,37 @@ impl Thunk {
// WARNING: avoid normalizing any thunk while holding on to this ref
// or you could run into BorrowMut panics
- pub fn normalize_nf(&self) -> Ref<Value> {
+ pub(crate) 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 fn as_value(&self) -> Ref<Value> {
+ pub(crate) fn as_value(&self) -> Ref<Value> {
self.do_normalize_whnf();
Ref::map(self.0.borrow(), ThunkInternal::as_whnf)
}
- pub fn to_value(&self) -> Value {
+ pub(crate) fn to_value(&self) -> Value {
self.as_value().clone()
}
- pub fn normalize_to_expr_maybe_alpha(&self, alpha: bool) -> OutputSubExpr {
+ pub(crate) fn normalize_to_expr_maybe_alpha(&self, alpha: bool) -> OutputSubExpr {
self.normalize_nf().normalize_to_expr_maybe_alpha(alpha)
}
- pub fn app_val(&self, val: Value) -> Value {
+ pub(crate) fn app_val(&self, val: Value) -> Value {
self.app_thunk(val.into_thunk())
}
- pub fn app_thunk(&self, th: Thunk) -> Value {
+ pub(crate) fn app_thunk(&self, th: Thunk) -> Value {
apply_any(self.clone(), th)
}
}
impl TypedThunk {
- pub fn from_value(v: Value) -> TypedThunk {
+ pub(crate) fn from_value(v: Value) -> TypedThunk {
TypedThunk::from_thunk(Thunk::from_value(v))
}
@@ -205,11 +205,11 @@ impl TypedThunk {
TypedThunk::from_thunk_untyped(th)
}
- pub fn from_type(t: Type) -> TypedThunk {
+ pub(crate) fn from_type(t: Type) -> TypedThunk {
t.into_typethunk()
}
- pub fn normalize_nf(&self) -> Value {
+ pub(crate) fn normalize_nf(&self) -> Value {
match self {
TypedThunk::Const(c) => Value::Const(*c),
TypedThunk::Untyped(thunk) | TypedThunk::Typed(thunk, _) => {
@@ -218,53 +218,53 @@ impl TypedThunk {
}
}
- pub fn to_typed(&self) -> Typed {
+ pub(crate) fn to_typed(&self) -> Typed {
self.clone().into_typed()
}
- pub fn normalize_to_expr_maybe_alpha(&self, alpha: bool) -> OutputSubExpr {
+ pub(crate) fn normalize_to_expr_maybe_alpha(&self, alpha: bool) -> OutputSubExpr {
self.normalize_nf().normalize_to_expr_maybe_alpha(alpha)
}
- pub fn from_thunk_and_type(th: Thunk, t: Type) -> Self {
+ pub(crate) fn from_thunk_and_type(th: Thunk, t: Type) -> Self {
TypedThunk::Typed(th, Box::new(t))
}
- pub fn from_thunk_untyped(th: Thunk) -> Self {
+ pub(crate) fn from_thunk_untyped(th: Thunk) -> Self {
TypedThunk::Untyped(th)
}
- pub fn from_const(c: Const) -> Self {
+ pub(crate) fn from_const(c: Const) -> Self {
TypedThunk::Const(c)
}
- pub fn from_value_untyped(v: Value) -> Self {
+ pub(crate) fn from_value_untyped(v: Value) -> Self {
TypedThunk::from_thunk_untyped(Thunk::from_value(v))
}
// TODO: Avoid cloning if possible
- pub fn to_value(&self) -> Value {
+ pub(crate) fn to_value(&self) -> Value {
match self {
TypedThunk::Untyped(th) | TypedThunk::Typed(th, _) => th.to_value(),
TypedThunk::Const(c) => Value::Const(*c),
}
}
- pub fn to_expr(&self) -> NormalizedSubExpr {
+ pub(crate) fn to_expr(&self) -> NormalizedSubExpr {
self.to_value().normalize_to_expr()
}
- pub fn to_expr_alpha(&self) -> NormalizedSubExpr {
+ pub(crate) fn to_expr_alpha(&self) -> NormalizedSubExpr {
self.to_value().normalize_to_expr_maybe_alpha(true)
}
- pub fn to_thunk(&self) -> Thunk {
+ pub(crate) fn to_thunk(&self) -> Thunk {
match self {
TypedThunk::Untyped(th) | TypedThunk::Typed(th, _) => th.clone(),
TypedThunk::Const(c) => Thunk::from_value(Value::Const(*c)),
}
}
- pub fn to_type(&self) -> Type {
+ pub(crate) fn to_type(&self) -> Type {
self.clone().into_typed().into_type()
}
- pub fn into_typed(self) -> Typed {
+ pub(crate) fn into_typed(self) -> Typed {
Typed::from_typethunk(self)
}
- pub fn as_const(&self) -> Option<Const> {
+ pub(crate) fn as_const(&self) -> Option<Const> {
// TODO: avoid clone
match &self.to_value() {
Value::Const(c) => Some(*c),
@@ -272,7 +272,7 @@ impl TypedThunk {
}
}
- pub fn normalize_mut(&mut self) {
+ pub(crate) fn normalize_mut(&mut self) {
match self {
TypedThunk::Untyped(th) | TypedThunk::Typed(th, _) => {
th.normalize_mut()
@@ -281,7 +281,7 @@ impl TypedThunk {
}
}
- pub fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> {
+ pub(crate) fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> {
match self {
TypedThunk::Untyped(_) => Err(TypeError::new(
&TypecheckContext::new(),
diff --git a/dhall/src/core/value.rs b/dhall/src/core/value.rs
index 19be56a..61a8eea 100644
--- a/dhall/src/core/value.rs
+++ b/dhall/src/core/value.rs
@@ -56,17 +56,17 @@ pub enum Value {
}
impl Value {
- pub fn into_thunk(self) -> Thunk {
+ pub(crate) fn into_thunk(self) -> Thunk {
Thunk::from_value(self)
}
/// Convert the value to a fully normalized syntactic expression
- pub fn normalize_to_expr(&self) -> OutputSubExpr {
+ pub(crate) 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 fn normalize_to_expr_maybe_alpha(&self, alpha: bool) -> OutputSubExpr {
+ pub(crate) 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),
@@ -179,14 +179,7 @@ impl Value {
}
}
- // Deprecated
- pub fn normalize(&self) -> Value {
- let mut v = self.clone();
- v.normalize_mut();
- v
- }
-
- pub fn normalize_mut(&mut self) {
+ pub(crate) fn normalize_mut(&mut self) {
match self {
Value::Var(_)
| Value::Const(_)
@@ -264,12 +257,12 @@ impl Value {
}
/// Apply to a value
- pub fn app(self, val: Value) -> Value {
+ pub(crate) fn app(self, val: Value) -> Value {
self.app_val(val)
}
/// Apply to a value
- pub fn app_val(self, val: Value) -> Value {
+ pub(crate) fn app_val(self, val: Value) -> Value {
self.app_thunk(val.into_thunk())
}
diff --git a/dhall/src/core/var.rs b/dhall/src/core/var.rs
index d53c194..4ef1b93 100644
--- a/dhall/src/core/var.rs
+++ b/dhall/src/core/var.rs
@@ -16,7 +16,7 @@ pub struct AlphaVar {
#[derive(Clone, Eq)]
pub struct AlphaLabel(Label);
-pub trait Shift: Sized {
+pub(crate) 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,24 +50,24 @@ pub trait Shift: Sized {
}
}
-pub trait Subst<T> {
+pub(crate) trait Subst<T> {
fn subst_shift(&self, var: &AlphaVar, val: &T) -> Self;
}
impl AlphaVar {
- pub fn to_var(&self, alpha: bool) -> V<Label> {
+ pub(crate) fn to_var(&self, alpha: bool) -> V<Label> {
match (alpha, &self.alpha) {
(true, Some(x)) => V("_".into(), x.1),
_ => self.normal.clone(),
}
}
- pub fn from_var(normal: V<Label>) -> Self {
+ pub(crate) fn from_var(normal: V<Label>) -> Self {
AlphaVar {
normal,
alpha: None,
}
}
- pub fn from_var_and_alpha(normal: V<Label>, alpha: usize) -> Self {
+ pub(crate) fn from_var_and_alpha(normal: V<Label>, alpha: usize) -> Self {
AlphaVar {
normal,
alpha: Some(V((), alpha)),
@@ -76,14 +76,14 @@ impl AlphaVar {
}
impl AlphaLabel {
- pub fn to_label_maybe_alpha(&self, alpha: bool) -> Label {
+ pub(crate) fn to_label_maybe_alpha(&self, alpha: bool) -> Label {
if alpha {
"_".into()
} else {
self.to_label()
}
}
- pub fn to_label(&self) -> Label {
+ pub(crate) fn to_label(&self) -> Label {
self.clone().into()
}
}
diff --git a/dhall/src/phase/binary.rs b/dhall/src/phase/binary.rs
index 36dd471..3746635 100644
--- a/dhall/src/phase/binary.rs
+++ b/dhall/src/phase/binary.rs
@@ -11,14 +11,14 @@ use dhall_syntax::{
use crate::error::{DecodeError, EncodeError};
use crate::phase::DecodedSubExpr;
-pub fn decode(data: &[u8]) -> Result<DecodedSubExpr, DecodeError> {
+pub(crate) fn decode(data: &[u8]) -> Result<DecodedSubExpr, DecodeError> {
match serde_cbor::de::from_slice(data) {
Ok(v) => cbor_value_to_dhall(&v),
Err(e) => Err(DecodeError::CBORError(e)),
}
}
-pub fn encode<E>(expr: &SubExpr<E>) -> Result<Vec<u8>, EncodeError> {
+pub(crate) fn encode<E>(expr: &SubExpr<E>) -> Result<Vec<u8>, EncodeError> {
serde_cbor::ser::to_vec(&Serialize::Expr(expr))
.map_err(|e| EncodeError::CBORError(e))
}
diff --git a/dhall/src/phase/mod.rs b/dhall/src/phase/mod.rs
index 2700e99..778f990 100644
--- a/dhall/src/phase/mod.rs
+++ b/dhall/src/phase/mod.rs
@@ -50,11 +50,9 @@ impl Parsed {
pub fn parse_str(s: &str) -> Result<Parsed, Error> {
parse::parse_str(s)
}
- #[allow(dead_code)]
pub fn parse_binary_file(f: &Path) -> Result<Parsed, Error> {
parse::parse_binary_file(f)
}
- #[allow(dead_code)]
pub fn parse_binary(data: &[u8]) -> Result<Parsed, Error> {
parse::parse_binary(data)
}
@@ -62,12 +60,10 @@ impl Parsed {
pub fn resolve(self) -> Result<Resolved, ImportError> {
resolve::resolve(self)
}
- #[allow(dead_code)]
pub fn skip_resolve(self) -> Result<Resolved, ImportError> {
resolve::skip_resolve_expr(self)
}
- #[allow(dead_code)]
pub fn encode(&self) -> Result<Vec<u8>, EncodeError> {
crate::phase::binary::encode(&self.0)
}
@@ -82,7 +78,7 @@ impl Resolved {
}
/// Pretends this expression has been typechecked. Use with care.
#[allow(dead_code)]
- pub fn skip_typecheck(self) -> Typed {
+ pub(crate) fn skip_typecheck(self) -> Typed {
typecheck::skip_typecheck(self)
}
}
@@ -101,29 +97,29 @@ impl Typed {
Normalized(self)
}
- pub fn from_thunk_and_type(th: Thunk, t: Type) -> Self {
+ pub(crate) fn from_thunk_and_type(th: Thunk, t: Type) -> Self {
Typed(TypedThunk::from_thunk_and_type(th, t))
}
- pub fn from_thunk_untyped(th: Thunk) -> Self {
+ pub(crate) fn from_thunk_untyped(th: Thunk) -> Self {
Typed(TypedThunk::from_thunk_untyped(th))
}
- pub fn from_const(c: Const) -> Self {
+ pub(crate) fn from_const(c: Const) -> Self {
Typed(TypedThunk::from_const(c))
}
pub fn from_value_untyped(v: Value) -> Self {
Typed(TypedThunk::from_value_untyped(v))
}
- pub fn from_typethunk(th: TypedThunk) -> Self {
+ pub(crate) fn from_typethunk(th: TypedThunk) -> Self {
Typed(th)
}
- pub fn to_value(&self) -> Value {
+ pub(crate) fn to_value(&self) -> Value {
self.0.to_value()
}
pub fn to_expr(&self) -> NormalizedSubExpr {
self.0.to_expr()
}
- pub fn to_expr_alpha(&self) -> NormalizedSubExpr {
+ pub(crate) fn to_expr_alpha(&self) -> NormalizedSubExpr {
self.0.to_expr_alpha()
}
pub fn to_thunk(&self) -> Thunk {
@@ -134,24 +130,24 @@ impl Typed {
self.clone()
}
// Deprecated
- pub fn into_type(self) -> Type {
+ pub(crate) fn into_type(self) -> Type {
self
}
- pub fn into_typethunk(self) -> TypedThunk {
+ pub(crate) fn into_typethunk(self) -> TypedThunk {
self.0
}
- pub fn to_normalized(&self) -> Normalized {
+ pub(crate) fn to_normalized(&self) -> Normalized {
self.clone().normalize()
}
- pub fn as_const(&self) -> Option<Const> {
+ pub(crate) fn as_const(&self) -> Option<Const> {
self.0.as_const()
}
- pub fn normalize_mut(&mut self) {
+ pub(crate) fn normalize_mut(&mut self) {
self.0.normalize_mut()
}
- pub fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> {
+ pub(crate) fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> {
self.0.get_type()
}
}
@@ -161,22 +157,21 @@ impl Normalized {
crate::phase::binary::encode(&self.to_expr())
}
- #[allow(dead_code)]
- pub fn to_expr(&self) -> NormalizedSubExpr {
+ pub(crate) fn to_expr(&self) -> NormalizedSubExpr {
self.0.to_expr()
}
#[allow(dead_code)]
- pub fn to_expr_alpha(&self) -> NormalizedSubExpr {
+ pub(crate) fn to_expr_alpha(&self) -> NormalizedSubExpr {
self.0.to_expr_alpha()
}
#[allow(dead_code)]
- pub fn to_type(&self) -> Type {
+ pub(crate) fn to_type(&self) -> Type {
self.0.to_type()
}
- pub fn to_value(&self) -> Value {
+ pub(crate) fn to_value(&self) -> Value {
self.0.to_value()
}
- pub fn into_typed(self) -> Typed {
+ pub(crate) fn into_typed(self) -> Typed {
self.0
}
}
diff --git a/dhall/src/phase/normalize.rs b/dhall/src/phase/normalize.rs
index 02406f2..fd0197d 100644
--- a/dhall/src/phase/normalize.rs
+++ b/dhall/src/phase/normalize.rs
@@ -11,8 +11,8 @@ use crate::core::value::Value;
use crate::core::var::{Shift, Subst};
use crate::phase::{Normalized, NormalizedSubExpr, ResolvedSubExpr, Typed};
-pub type InputSubExpr = ResolvedSubExpr;
-pub type OutputSubExpr = NormalizedSubExpr;
+pub(crate) type InputSubExpr = ResolvedSubExpr;
+pub(crate) type OutputSubExpr = NormalizedSubExpr;
// Ad-hoc macro to help construct closures
macro_rules! make_closure {
@@ -57,7 +57,7 @@ macro_rules! make_closure {
}
#[allow(clippy::cognitive_complexity)]
-pub fn apply_builtin(b: Builtin, args: Vec<Thunk>) -> Value {
+pub(crate) fn apply_builtin(b: Builtin, args: Vec<Thunk>) -> Value {
use dhall_syntax::Builtin::*;
use Value::*;
@@ -315,7 +315,7 @@ pub fn apply_builtin(b: Builtin, args: Vec<Thunk>) -> Value {
}
}
-pub fn apply_any(f: Thunk, a: Thunk) -> Value {
+pub(crate) 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();
@@ -339,7 +339,7 @@ pub fn apply_any(f: Thunk, a: Thunk) -> Value {
}
}
-pub fn squash_textlit(
+pub(crate) fn squash_textlit(
elts: impl Iterator<Item = InterpolatedTextContents<Thunk>>,
) -> Vec<InterpolatedTextContents<Thunk>> {
use std::mem::replace;
@@ -382,7 +382,7 @@ pub fn squash_textlit(
}
/// Reduces the imput expression to a Value. Evaluates as little as possible.
-pub fn normalize_whnf(ctx: NormalizationContext, expr: InputSubExpr) -> Value {
+pub(crate) 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),
@@ -649,7 +649,7 @@ fn apply_binop<'a>(o: BinOp, x: &'a Thunk, y: &'a Thunk) -> Option<Ret<'a>> {
})
}
-pub fn normalize_one_layer(expr: ExprF<Thunk, Normalized>) -> Value {
+pub(crate) fn normalize_one_layer(expr: ExprF<Thunk, Normalized>) -> Value {
use Value::{
AppliedBuiltin, BoolLit, DoubleLit, EmptyListLit, IntegerLit, Lam,
NEListLit, NEOptionalLit, NaturalLit, Pi, RecordLit, RecordType,
diff --git a/dhall/src/phase/parse.rs b/dhall/src/phase/parse.rs
index 9f3f2f4..540ceea 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 fn parse_file(f: &Path) -> Result<Parsed, Error> {
+pub(crate) 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,19 +16,19 @@ pub fn parse_file(f: &Path) -> Result<Parsed, Error> {
Ok(Parsed(expr, root))
}
-pub fn parse_str(s: &str) -> Result<Parsed, Error> {
+pub(crate) 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 fn parse_binary(data: &[u8]) -> Result<Parsed, Error> {
+pub(crate) fn parse_binary(data: &[u8]) -> Result<Parsed, Error> {
let expr = crate::phase::binary::decode(data)?;
let root = ImportRoot::LocalDir(std::env::current_dir()?);
Ok(Parsed(expr, root))
}
-pub fn parse_binary_file(f: &Path) -> Result<Parsed, Error> {
+pub(crate) 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 dabecf2..27ae7a3 100644
--- a/dhall/src/phase/resolve.rs
+++ b/dhall/src/phase/resolve.rs
@@ -8,13 +8,13 @@ type Import = dhall_syntax::Import<NormalizedSubExpr>;
/// A root from which to resolve relative imports.
#[derive(Debug, Clone, PartialEq, Eq)]
-pub enum ImportRoot {
+pub(crate) enum ImportRoot {
LocalDir(PathBuf),
}
type ImportCache = HashMap<Import, Normalized>;
-pub type ImportStack = Vec<Import>;
+pub(crate) type ImportStack = Vec<Import>;
fn resolve_import(
import: &Import,
@@ -90,11 +90,11 @@ fn do_resolve_expr(
Ok(Resolved(expr))
}
-pub fn resolve(e: Parsed) -> Result<Resolved, ImportError> {
+pub(crate) fn resolve(e: Parsed) -> Result<Resolved, ImportError> {
do_resolve_expr(e, &mut HashMap::new(), &Vec::new())
}
-pub fn skip_resolve_expr(
+pub(crate) 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 5eab8da..56fb5ed 100644
--- a/dhall/src/phase/typecheck.rs
+++ b/dhall/src/phase/typecheck.rs
@@ -147,7 +147,7 @@ fn function_check(a: Const, b: Const) -> Const {
}
}
-pub fn type_of_const(c: Const) -> Result<Type, TypeError> {
+pub(crate) 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)),
@@ -300,14 +300,14 @@ fn type_of_builtin<E>(b: Builtin) -> Expr<E> {
/// Takes an expression that is meant to contain a Type
/// and turn it into a type, typechecking it along the way.
-pub fn mktype(
+pub(crate) fn mktype(
ctx: &TypecheckContext,
e: SubExpr<Normalized>,
) -> Result<Type, TypeError> {
Ok(type_with(ctx, e)?.to_type())
}
-pub fn builtin_to_type(b: Builtin) -> Result<Type, TypeError> {
+pub(crate) fn builtin_to_type(b: Builtin) -> Result<Type, TypeError> {
mktype(&TypecheckContext::new(), SubExpr::from_builtin(b))
}
@@ -1009,15 +1009,15 @@ fn type_of(e: SubExpr<Normalized>) -> Result<Typed, TypeError> {
Ok(e)
}
-pub fn typecheck(e: Resolved) -> Result<Typed, TypeError> {
+pub(crate) fn typecheck(e: Resolved) -> Result<Typed, TypeError> {
type_of(e.0)
}
-pub fn typecheck_with(e: Resolved, ty: &Type) -> Result<Typed, TypeError> {
+pub(crate) fn typecheck_with(e: Resolved, ty: &Type) -> Result<Typed, TypeError> {
let expr: SubExpr<_> = e.0;
let ty: SubExpr<_> = ty.to_expr();
type_of(expr.rewrap(ExprF::Annot(expr.clone(), ty)))
}
-pub fn skip_typecheck(e: Resolved) -> Typed {
+pub(crate) fn skip_typecheck(e: Resolved) -> Typed {
Typed::from_thunk_untyped(Thunk::new(NormalizationContext::new(), e.0))
}