summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2020-03-18 18:58:51 +0000
committerNadrieril2020-03-31 21:44:01 +0100
commit7848c8e8d3147ebe428290558aa6c0efcbf59ee5 (patch)
treebe25355f0fabf6bc5f9b0568e224795058f069a6
parent844dc3defdd7735742ad41eb6d1da8fe2e7f340b (diff)
Brutally make all of dhall pub
-rw-r--r--dhall/README.md9
-rw-r--r--dhall/src/error/builder.rs2
-rw-r--r--dhall/src/error/mod.rs14
-rw-r--r--dhall/src/lib.rs30
-rw-r--r--dhall/src/semantics/builtins.rs6
-rw-r--r--dhall/src/semantics/mod.rs8
-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
-rw-r--r--dhall/src/semantics/parse.rs10
-rw-r--r--dhall/src/semantics/resolve/env.rs8
-rw-r--r--dhall/src/semantics/resolve/hir.rs8
-rw-r--r--dhall/src/semantics/resolve/mod.rs6
-rw-r--r--dhall/src/semantics/resolve/resolve.rs10
-rw-r--r--dhall/src/semantics/tck/env.rs4
-rw-r--r--dhall/src/semantics/tck/mod.rs6
-rw-r--r--dhall/src/semantics/tck/tir.rs6
-rw-r--r--dhall/src/semantics/tck/typecheck.rs10
-rw-r--r--dhall/src/simple.rs8
-rw-r--r--dhall/src/syntax/ast/expr.rs10
-rw-r--r--dhall/src/syntax/ast/mod.rs2
-rw-r--r--dhall/src/syntax/ast/span.rs12
-rw-r--r--dhall/src/syntax/ast/visitor.rs2
-rw-r--r--dhall/src/syntax/binary/decode.rs2
-rw-r--r--dhall/src/syntax/binary/encode.rs2
-rw-r--r--dhall/src/syntax/binary/mod.rs4
28 files changed, 125 insertions, 124 deletions
diff --git a/dhall/README.md b/dhall/README.md
index 82b3e6a..25f11f7 100644
--- a/dhall/README.md
+++ b/dhall/README.md
@@ -1,10 +1,11 @@
# `dhall`
Implementation of the Dhall configuration language.
-This is an internal crate used for [`serde_dhall`], you probably want to use
-that instead.
-The API is very unstable and does not respect semver;
-use at your own risk.
+WARNING: This is an internal crate used for [`serde_dhall`], you probably want
+to use that instead.
+
+WARNING: The API is very unstable and does not respect semver; use at your own
+risk.
[`serde_dhall`]: https://docs.rs/serde_dhall
diff --git a/dhall/src/error/builder.rs b/dhall/src/error/builder.rs
index c0bacb5..3ee65fb 100644
--- a/dhall/src/error/builder.rs
+++ b/dhall/src/error/builder.rs
@@ -6,7 +6,7 @@ use annotate_snippets::{
use crate::syntax::{ParsedSpan, Span};
#[derive(Debug, Clone, Default)]
-pub(crate) struct ErrorBuilder {
+pub struct ErrorBuilder {
title: FreeAnnotation,
annotations: Vec<SpannedAnnotation>,
footer: Vec<FreeAnnotation>,
diff --git a/dhall/src/error/mod.rs b/dhall/src/error/mod.rs
index e28b98b..ef4d41f 100644
--- a/dhall/src/error/mod.rs
+++ b/dhall/src/error/mod.rs
@@ -4,7 +4,7 @@ use crate::semantics::resolve::{ImportLocation, ImportStack};
use crate::syntax::{Import, ParseError};
mod builder;
-pub(crate) use builder::*;
+pub use builder::*;
pub type Result<T> = std::result::Result<T, Error>;
@@ -15,7 +15,7 @@ pub struct Error {
#[derive(Debug)]
#[non_exhaustive]
-pub(crate) enum ErrorKind {
+pub enum ErrorKind {
IO(IOError),
Parse(ParseError),
Decode(DecodeError),
@@ -25,7 +25,7 @@ pub(crate) enum ErrorKind {
}
#[derive(Debug)]
-pub(crate) enum ImportError {
+pub enum ImportError {
Missing,
MissingEnvVar,
SanityCheck,
@@ -53,21 +53,21 @@ pub struct TypeError {
/// The specific type error
#[derive(Debug)]
-pub(crate) enum TypeMessage {
+pub enum TypeMessage {
Custom(String),
}
impl Error {
- pub(crate) fn new(kind: ErrorKind) -> Self {
+ pub fn new(kind: ErrorKind) -> Self {
Error { kind }
}
- pub(crate) fn kind(&self) -> &ErrorKind {
+ pub fn kind(&self) -> &ErrorKind {
&self.kind
}
}
impl TypeError {
- pub(crate) fn new(message: TypeMessage) -> Self {
+ pub fn new(message: TypeMessage) -> Self {
TypeError { message }
}
}
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs
index caaf260..34a9bac 100644
--- a/dhall/src/lib.rs
+++ b/dhall/src/lib.rs
@@ -26,17 +26,17 @@ use crate::syntax::Expr;
pub use crate::simple::{STyKind, SValKind, SimpleType, SimpleValue};
#[derive(Debug, Clone)]
-pub(crate) struct Parsed(Expr, ImportLocation);
+pub struct Parsed(Expr, ImportLocation);
/// An expression where all imports have been resolved
///
/// Invariant: there must be no `Import` nodes or `ImportAlt` operations left.
#[derive(Debug, Clone)]
-pub(crate) struct Resolved(Hir);
+pub struct Resolved(Hir);
/// A typed expression
#[derive(Debug, Clone)]
-pub(crate) struct Typed {
+pub struct Typed {
hir: Hir,
ty: Type,
}
@@ -45,23 +45,23 @@ pub(crate) struct Typed {
///
/// This is actually a lie, because the expression will only get normalized on demand.
#[derive(Debug, Clone)]
-pub(crate) struct Normalized(Nir);
+pub struct Normalized(Nir);
/// A Dhall value.
#[derive(Debug, Clone)]
pub struct Value {
/// Invariant: in normal form
- pub(crate) hir: Hir,
+ pub hir: Hir,
/// Cached conversions because they are annoying to construct from Hir.
- pub(crate) as_simple_val: Option<SimpleValue>,
- pub(crate) as_simple_ty: Option<SimpleType>,
+ pub as_simple_val: Option<SimpleValue>,
+ pub as_simple_ty: Option<SimpleType>,
}
/// Controls conversion from `Nir` to `Expr`
#[derive(Copy, Clone, Default)]
-pub(crate) struct ToExprOptions {
+pub struct ToExprOptions {
/// Whether to convert all variables to `_`
- pub(crate) alpha: bool,
+ pub alpha: bool,
}
impl Parsed {
@@ -96,7 +96,7 @@ impl Resolved {
pub fn typecheck(&self) -> Result<Typed, TypeError> {
Ok(Typed::from_tir(typecheck(&self.0)?))
}
- pub(crate) fn typecheck_with(self, ty: &Hir) -> Result<Typed, TypeError> {
+ pub fn typecheck_with(self, ty: &Hir) -> Result<Typed, TypeError> {
Ok(Typed::from_tir(typecheck_with(&self.0, ty)?))
}
/// Converts a value back to the corresponding AST expression.
@@ -122,10 +122,10 @@ impl Typed {
self.hir.to_expr(ToExprOptions { alpha: false })
}
- pub(crate) fn ty(&self) -> &Type {
+ pub fn ty(&self) -> &Type {
&self.ty
}
- pub(crate) fn get_type(&self) -> Result<Normalized, TypeError> {
+ pub fn get_type(&self) -> Result<Normalized, TypeError> {
Ok(Normalized(self.ty.clone().into_nir()))
}
}
@@ -144,11 +144,11 @@ impl Normalized {
self.0.to_expr(ToExprOptions::default())
}
/// Converts a value back to the corresponding Hir expression.
- pub(crate) fn to_hir(&self) -> Hir {
+ pub fn to_hir(&self) -> Hir {
self.0.to_hir_noenv()
}
/// Converts a value back to the corresponding AST expression, alpha-normalizing in the process.
- pub(crate) fn to_expr_alpha(&self) -> Expr {
+ pub fn to_expr_alpha(&self) -> Expr {
self.0.to_expr(ToExprOptions { alpha: true })
}
}
@@ -178,7 +178,7 @@ impl Value {
}
/// Converts a value back to the corresponding AST expression.
- pub(crate) fn to_expr(&self) -> Expr {
+ pub fn to_expr(&self) -> Expr {
self.hir.to_expr(ToExprOptions::default())
}
}
diff --git a/dhall/src/semantics/builtins.rs b/dhall/src/semantics/builtins.rs
index ef375b8..fa22bd0 100644
--- a/dhall/src/semantics/builtins.rs
+++ b/dhall/src/semantics/builtins.rs
@@ -14,7 +14,7 @@ use std::convert::TryInto;
/// A partially applied builtin.
/// Invariant: the evaluation of the given args must not be able to progress further
#[derive(Debug, Clone)]
-pub(crate) struct BuiltinClosure {
+pub struct BuiltinClosure {
env: NzEnv,
b: Builtin,
/// Arguments applied to the closure so far.
@@ -43,7 +43,7 @@ impl BuiltinClosure {
}
}
-pub(crate) fn rc(x: UnspannedExpr) -> Expr {
+pub fn rc(x: UnspannedExpr) -> Expr {
Expr::new(x, Span::Artificial)
}
@@ -103,7 +103,7 @@ macro_rules! make_type {
};
}
-pub(crate) fn type_of_builtin(b: Builtin) -> Hir {
+pub fn type_of_builtin(b: Builtin) -> Hir {
use Builtin::*;
let expr = match b {
Bool | Natural | Integer | Double | Text => make_type!(Type),
diff --git a/dhall/src/semantics/mod.rs b/dhall/src/semantics/mod.rs
index 87033c9..468d8b1 100644
--- a/dhall/src/semantics/mod.rs
+++ b/dhall/src/semantics/mod.rs
@@ -3,7 +3,7 @@ pub mod nze;
pub mod parse;
pub mod resolve;
pub mod tck;
-pub(crate) use self::builtins::*;
-pub(crate) use self::nze::*;
-pub(crate) use self::resolve::*;
-pub(crate) use self::tck::*;
+pub use self::builtins::*;
+pub use self::nze::*;
+pub use self::resolve::*;
+pub use self::tck::*;
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()
}
}
diff --git a/dhall/src/semantics/parse.rs b/dhall/src/semantics/parse.rs
index 45860d0..2326471 100644
--- a/dhall/src/semantics/parse.rs
+++ b/dhall/src/semantics/parse.rs
@@ -9,33 +9,33 @@ use crate::syntax::binary;
use crate::syntax::parse_expr;
use crate::Parsed;
-pub(crate) fn parse_file(f: &Path) -> Result<Parsed, Error> {
+pub fn parse_file(f: &Path) -> Result<Parsed, Error> {
let text = std::fs::read_to_string(f)?;
let expr = parse_expr(&text)?;
let root = ImportLocation::Local(f.to_owned());
Ok(Parsed(expr, root))
}
-pub(crate) fn parse_remote(url: Url) -> Result<Parsed, Error> {
+pub fn parse_remote(url: Url) -> Result<Parsed, Error> {
let body = reqwest::blocking::get(url.clone()).unwrap().text().unwrap();
let expr = parse_expr(&body)?;
let root = ImportLocation::Remote(url);
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 = ImportLocation::Missing;
Ok(Parsed(expr, root))
}
-pub(crate) fn parse_binary(data: &[u8]) -> Result<Parsed, Error> {
+pub fn parse_binary(data: &[u8]) -> Result<Parsed, Error> {
let expr = binary::decode(data)?;
let root = ImportLocation::Missing;
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 = binary::decode(&buffer)?;
diff --git a/dhall/src/semantics/resolve/env.rs b/dhall/src/semantics/resolve/env.rs
index fe8c178..d5bb15b 100644
--- a/dhall/src/semantics/resolve/env.rs
+++ b/dhall/src/semantics/resolve/env.rs
@@ -6,16 +6,16 @@ use crate::syntax::{Label, V};
/// Environment for resolving names.
#[derive(Debug, Clone)]
-pub(crate) struct NameEnv {
+pub struct NameEnv {
names: Vec<Label>,
}
-pub(crate) type ImportCache = HashMap<ImportLocation, TypedHir>;
-pub(crate) type ImportStack = Vec<ImportLocation>;
+pub type ImportCache = HashMap<ImportLocation, TypedHir>;
+pub type ImportStack = Vec<ImportLocation>;
/// Environment for resolving imports
#[derive(Debug, Clone)]
-pub(crate) struct ImportEnv {
+pub struct ImportEnv {
cache: ImportCache,
stack: ImportStack,
}
diff --git a/dhall/src/semantics/resolve/hir.rs b/dhall/src/semantics/resolve/hir.rs
index 3934bbb..9256425 100644
--- a/dhall/src/semantics/resolve/hir.rs
+++ b/dhall/src/semantics/resolve/hir.rs
@@ -10,7 +10,7 @@ pub struct AlphaVar {
}
#[derive(Debug, Clone, PartialEq, Eq)]
-pub(crate) enum HirKind {
+pub enum HirKind {
/// A resolved variable (i.e. a DeBruijn index)
Var(AlphaVar),
/// Result of resolving an import.
@@ -21,16 +21,16 @@ pub(crate) enum HirKind {
// An expression with resolved variables and imports.
#[derive(Debug, Clone)]
-pub(crate) struct Hir {
+pub struct Hir {
kind: Box<HirKind>,
span: Span,
}
impl AlphaVar {
- pub(crate) fn new(idx: usize) -> Self {
+ pub fn new(idx: usize) -> Self {
AlphaVar { idx }
}
- pub(crate) fn idx(self) -> usize {
+ pub fn idx(self) -> usize {
self.idx
}
}
diff --git a/dhall/src/semantics/resolve/mod.rs b/dhall/src/semantics/resolve/mod.rs
index 517907b..33b477e 100644
--- a/dhall/src/semantics/resolve/mod.rs
+++ b/dhall/src/semantics/resolve/mod.rs
@@ -1,6 +1,6 @@
pub mod env;
pub mod hir;
pub mod resolve;
-pub(crate) use env::*;
-pub(crate) use hir::*;
-pub(crate) use resolve::*;
+pub use env::*;
+pub use hir::*;
+pub use resolve::*;
diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs
index eb2f04f..07bd06c 100644
--- a/dhall/src/semantics/resolve/resolve.rs
+++ b/dhall/src/semantics/resolve/resolve.rs
@@ -16,14 +16,14 @@ use crate::syntax::{
use crate::{Parsed, Resolved};
// TODO: evaluate import headers
-pub(crate) type Import = syntax::Import<()>;
+pub type Import = syntax::Import<()>;
/// Owned Hir with a type. Different from Tir because the Hir is owned.
-pub(crate) type TypedHir = (Hir, Type);
+pub type TypedHir = (Hir, Type);
/// The location of some data, usually some dhall code.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub(crate) enum ImportLocation {
+pub enum ImportLocation {
/// Local file
Local(PathBuf),
/// Remote file
@@ -329,11 +329,11 @@ fn resolve_with_env(
Ok(Resolved(resolved))
}
-pub(crate) fn resolve(parsed: Parsed) -> Result<Resolved, Error> {
+pub fn resolve(parsed: Parsed) -> Result<Resolved, Error> {
resolve_with_env(&mut ImportEnv::new(), parsed)
}
-pub(crate) fn skip_resolve(expr: &Expr) -> Result<Hir, Error> {
+pub fn skip_resolve(expr: &Expr) -> Result<Hir, Error> {
traverse_resolve_expr(&mut NameEnv::new(), expr, &mut |import| {
Err(ImportError::UnexpectedImport(import).into())
})
diff --git a/dhall/src/semantics/tck/env.rs b/dhall/src/semantics/tck/env.rs
index 6dd5076..f2ef00a 100644
--- a/dhall/src/semantics/tck/env.rs
+++ b/dhall/src/semantics/tck/env.rs
@@ -3,13 +3,13 @@ use crate::syntax::Label;
/// Environment for indexing variables.
#[derive(Debug, Clone, Copy)]
-pub(crate) struct VarEnv {
+pub struct VarEnv {
size: usize,
}
/// Environment for typing expressions.
#[derive(Debug, Clone)]
-pub(crate) struct TyEnv {
+pub struct TyEnv {
names: NameEnv,
items: ValEnv<Type>,
}
diff --git a/dhall/src/semantics/tck/mod.rs b/dhall/src/semantics/tck/mod.rs
index 93c8f48..6dddfc5 100644
--- a/dhall/src/semantics/tck/mod.rs
+++ b/dhall/src/semantics/tck/mod.rs
@@ -1,6 +1,6 @@
pub mod env;
pub mod tir;
pub mod typecheck;
-pub(crate) use env::*;
-pub(crate) use tir::*;
-pub(crate) use typecheck::*;
+pub use env::*;
+pub use tir::*;
+pub use typecheck::*;
diff --git a/dhall/src/semantics/tck/tir.rs b/dhall/src/semantics/tck/tir.rs
index 1865b8e..89a8027 100644
--- a/dhall/src/semantics/tck/tir.rs
+++ b/dhall/src/semantics/tck/tir.rs
@@ -4,11 +4,11 @@ use crate::syntax::{Builtin, Const, Expr, Span};
/// The type of a type. 0 is `Type`, 1 is `Kind`, etc...
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Default)]
-pub(crate) struct Universe(u8);
+pub struct Universe(u8);
/// An expression representing a type
#[derive(Debug, Clone, PartialEq, Eq)]
-pub(crate) struct Type {
+pub struct Type {
val: Nir,
univ: Universe,
}
@@ -16,7 +16,7 @@ pub(crate) struct Type {
/// A hir expression plus its inferred type.
/// Stands for "Typed intermediate representation"
#[derive(Debug, Clone)]
-pub(crate) struct Tir<'hir> {
+pub struct Tir<'hir> {
hir: &'hir Hir,
ty: Type,
}
diff --git a/dhall/src/semantics/tck/typecheck.rs b/dhall/src/semantics/tck/typecheck.rs
index 880ab22..205185f 100644
--- a/dhall/src/semantics/tck/typecheck.rs
+++ b/dhall/src/semantics/tck/typecheck.rs
@@ -53,11 +53,11 @@ fn function_check(a: Const, b: Const) -> Const {
}
}
-pub(crate) fn mkerr<T, S: ToString>(msg: S) -> Result<T, TypeError> {
+pub fn mkerr<T, S: ToString>(msg: S) -> Result<T, TypeError> {
Err(TypeError::new(TypeMessage::Custom(msg.to_string())))
}
-pub(crate) fn mk_span_err<T, S: ToString>(
+pub fn mk_span_err<T, S: ToString>(
span: Span,
msg: S,
) -> Result<T, TypeError> {
@@ -688,7 +688,7 @@ fn type_one_layer(
/// `type_with` typechecks an expression in the provided environment. Optionally pass an annotation
/// to compare with.
-pub(crate) fn type_with<'hir>(
+pub fn type_with<'hir>(
env: &TyEnv,
hir: &'hir Hir,
annot: Option<Type>,
@@ -785,12 +785,12 @@ pub(crate) fn type_with<'hir>(
/// Typecheck an expression and return the expression annotated with types if type-checking
/// succeeded, or an error if type-checking failed.
-pub(crate) fn typecheck<'hir>(hir: &'hir Hir) -> Result<Tir<'hir>, TypeError> {
+pub fn typecheck<'hir>(hir: &'hir Hir) -> Result<Tir<'hir>, TypeError> {
type_with(&TyEnv::new(), hir, None)
}
/// Like `typecheck`, but additionally checks that the expression's type matches the provided type.
-pub(crate) fn typecheck_with<'hir>(
+pub fn typecheck_with<'hir>(
hir: &'hir Hir,
ty: &Hir,
) -> Result<Tir<'hir>, TypeError> {
diff --git a/dhall/src/simple.rs b/dhall/src/simple.rs
index 45fa656..c00380c 100644
--- a/dhall/src/simple.rs
+++ b/dhall/src/simple.rs
@@ -38,12 +38,12 @@ pub enum STyKind {
}
impl SimpleValue {
- pub(crate) fn new(kind: SValKind) -> Self {
+ pub fn new(kind: SValKind) -> Self {
SimpleValue {
kind: Box::new(kind),
}
}
- pub(crate) fn from_nir(nir: &Nir) -> Option<Self> {
+ pub fn from_nir(nir: &Nir) -> Option<Self> {
Some(SimpleValue::new(match nir.kind() {
NirKind::Num(lit) => SValKind::Num(lit.clone()),
NirKind::TextLit(x) => SValKind::Text(
@@ -88,7 +88,7 @@ impl SimpleType {
kind: Box::new(kind),
}
}
- pub(crate) fn from_nir(nir: &Nir) -> Option<Self> {
+ pub fn from_nir(nir: &Nir) -> Option<Self> {
Some(SimpleType::new(match nir.kind() {
NirKind::BuiltinType(b) => match b {
Builtin::Bool => STyKind::Bool,
@@ -131,7 +131,7 @@ impl SimpleType {
as_simple_ty: Some(self.clone()),
}
}
- pub(crate) fn to_hir(&self) -> Hir {
+ pub fn to_hir(&self) -> Hir {
let hir = |k| Hir::new(HirKind::Expr(k), Span::Artificial);
hir(match self.kind() {
STyKind::Bool => ExprKind::Builtin(Builtin::Bool),
diff --git a/dhall/src/syntax/ast/expr.rs b/dhall/src/syntax/ast/expr.rs
index 2c1860e..6ba6649 100644
--- a/dhall/src/syntax/ast/expr.rs
+++ b/dhall/src/syntax/ast/expr.rs
@@ -22,7 +22,7 @@ pub enum Const {
}
impl Const {
- pub(crate) fn to_universe(self) -> Universe {
+ pub fn to_universe(self) -> Universe {
Universe::from_const(self)
}
}
@@ -205,7 +205,7 @@ impl<SE> ExprKind<SE> {
})
}
- pub(crate) fn traverse_ref<'a, SE2, Err>(
+ pub fn traverse_ref<'a, SE2, Err>(
&'a self,
mut visit_subexpr: impl FnMut(&'a SE) -> Result<SE2, Err>,
) -> Result<ExprKind<SE2>, Err> {
@@ -239,17 +239,17 @@ impl<SE> ExprKind<SE> {
}
impl Expr {
- pub(crate) fn as_ref(&self) -> &UnspannedExpr {
+ pub fn as_ref(&self) -> &UnspannedExpr {
&self.kind
}
pub fn kind(&self) -> &UnspannedExpr {
&self.kind
}
- pub(crate) fn span(&self) -> Span {
+ pub fn span(&self) -> Span {
self.span.clone()
}
- pub(crate) fn new(kind: UnspannedExpr, span: Span) -> Self {
+ pub fn new(kind: UnspannedExpr, span: Span) -> Self {
Expr {
kind: Box::new(kind),
span,
diff --git a/dhall/src/syntax/ast/mod.rs b/dhall/src/syntax/ast/mod.rs
index 5e20c5d..1950154 100644
--- a/dhall/src/syntax/ast/mod.rs
+++ b/dhall/src/syntax/ast/mod.rs
@@ -5,7 +5,7 @@ pub use import::*;
mod label;
pub use label::*;
mod span;
-pub(crate) use span::*;
+pub use span::*;
mod text;
pub use text::*;
pub mod map;
diff --git a/dhall/src/syntax/ast/span.rs b/dhall/src/syntax/ast/span.rs
index 2e09863..e250602 100644
--- a/dhall/src/syntax/ast/span.rs
+++ b/dhall/src/syntax/ast/span.rs
@@ -2,7 +2,7 @@ use std::rc::Rc;
/// A location in the source text
#[derive(Debug, Clone)]
-pub(crate) struct ParsedSpan {
+pub struct ParsedSpan {
input: Rc<str>,
/// # Safety
///
@@ -15,7 +15,7 @@ pub(crate) struct ParsedSpan {
}
#[derive(Debug, Clone)]
-pub(crate) enum Span {
+pub enum Span {
/// A location in the source text
Parsed(ParsedSpan),
/// Desugarings
@@ -30,12 +30,12 @@ pub(crate) enum Span {
}
impl ParsedSpan {
- pub(crate) fn to_input(&self) -> String {
+ pub fn to_input(&self) -> String {
self.input.to_string()
}
/// Convert to a char range for consumption by annotate_snippets.
/// This compensates for https://github.com/rust-lang/annotate-snippets-rs/issues/24
- pub(crate) fn as_char_range(&self) -> (usize, usize) {
+ pub fn as_char_range(&self) -> (usize, usize) {
(
char_idx_from_byte_idx(&self.input, self.start),
char_idx_from_byte_idx(&self.input, self.end),
@@ -44,7 +44,7 @@ impl ParsedSpan {
}
impl Span {
- pub(crate) fn make(input: Rc<str>, sp: pest::Span) -> Self {
+ pub fn make(input: Rc<str>, sp: pest::Span) -> Self {
Span::Parsed(ParsedSpan {
input,
start: sp.start(),
@@ -55,7 +55,7 @@ impl Span {
/// Takes the union of the two spans, i.e. the range of input covered by the two spans plus any
/// input between them. Assumes that the spans come from the same input. Fails if one of the
/// spans does not point to an input location.
- pub(crate) fn union(&self, other: &Span) -> Self {
+ pub fn union(&self, other: &Span) -> Self {
use std::cmp::{max, min};
use Span::*;
match (self, other) {
diff --git a/dhall/src/syntax/ast/visitor.rs b/dhall/src/syntax/ast/visitor.rs
index 0743af4..0a0c5ef 100644
--- a/dhall/src/syntax/ast/visitor.rs
+++ b/dhall/src/syntax/ast/visitor.rs
@@ -51,7 +51,7 @@ where
.collect()
}
-pub(crate) fn visit_ref<'a, F, SE1, SE2, Err>(
+pub fn visit_ref<'a, F, SE1, SE2, Err>(
input: &'a ExprKind<SE1>,
mut f: F,
) -> Result<ExprKind<SE2>, Err>
diff --git a/dhall/src/syntax/binary/decode.rs b/dhall/src/syntax/binary/decode.rs
index 0fd358e..3c93419 100644
--- a/dhall/src/syntax/binary/decode.rs
+++ b/dhall/src/syntax/binary/decode.rs
@@ -11,7 +11,7 @@ use crate::syntax::{
};
type DecodedExpr = Expr;
-pub(crate) fn decode(data: &[u8]) -> Result<DecodedExpr, DecodeError> {
+pub fn decode(data: &[u8]) -> Result<DecodedExpr, DecodeError> {
match serde_cbor::de::from_slice(data) {
Ok(v) => cbor_value_to_dhall(&v),
Err(e) => Err(DecodeError::CBORError(e)),
diff --git a/dhall/src/syntax/binary/encode.rs b/dhall/src/syntax/binary/encode.rs
index 5974f47..8d22a9b 100644
--- a/dhall/src/syntax/binary/encode.rs
+++ b/dhall/src/syntax/binary/encode.rs
@@ -10,7 +10,7 @@ use crate::syntax::{
Scheme, V,
};
-pub(crate) fn encode(expr: &Expr) -> Result<Vec<u8>, EncodeError> {
+pub fn encode(expr: &Expr) -> Result<Vec<u8>, EncodeError> {
serde_cbor::ser::to_vec(&Serialize::Expr(expr))
.map_err(EncodeError::CBORError)
}
diff --git a/dhall/src/syntax/binary/mod.rs b/dhall/src/syntax/binary/mod.rs
index 7ed1f6e..98e0520 100644
--- a/dhall/src/syntax/binary/mod.rs
+++ b/dhall/src/syntax/binary/mod.rs
@@ -1,4 +1,4 @@
mod decode;
mod encode;
-pub(crate) use decode::decode;
-pub(crate) use encode::encode;
+pub use decode::decode;
+pub use encode::encode;