diff options
-rw-r--r-- | dhall/src/core/context.rs | 2 | ||||
-rw-r--r-- | dhall/src/core/value.rs | 2 | ||||
-rw-r--r-- | dhall/src/core/valuef.rs | 4 | ||||
-rw-r--r-- | dhall/src/core/var.rs | 10 | ||||
-rw-r--r-- | dhall/src/error/mod.rs | 2 | ||||
-rw-r--r-- | dhall/src/lib.rs | 4 | ||||
-rw-r--r-- | dhall/src/phase/binary.rs | 16 | ||||
-rw-r--r-- | dhall/src/phase/mod.rs | 2 | ||||
-rw-r--r-- | dhall/src/phase/normalize.rs | 10 | ||||
-rw-r--r-- | dhall/src/phase/parse.rs | 2 | ||||
-rw-r--r-- | dhall/src/phase/resolve.rs | 8 | ||||
-rw-r--r-- | dhall/src/phase/typecheck.rs | 24 | ||||
-rw-r--r-- | serde_dhall/src/lib.rs | 2 | ||||
-rw-r--r-- | serde_dhall/src/serde.rs | 2 | ||||
-rw-r--r-- | serde_dhall/src/static_type.rs | 2 |
15 files changed, 48 insertions, 44 deletions
diff --git a/dhall/src/core/context.rs b/dhall/src/core/context.rs index 2bf39c5..00e1493 100644 --- a/dhall/src/core/context.rs +++ b/dhall/src/core/context.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::rc::Rc; -use dhall_syntax::{Label, V}; +use crate::syntax::{Label, V}; use crate::core::value::Value; use crate::core::valuef::ValueF; diff --git a/dhall/src/core/value.rs b/dhall/src/core/value.rs index d4f5131..bd7a9b9 100644 --- a/dhall/src/core/value.rs +++ b/dhall/src/core/value.rs @@ -1,7 +1,7 @@ use std::cell::{Ref, RefCell, RefMut}; use std::rc::Rc; -use dhall_syntax::{Builtin, Const, Span}; +use crate::syntax::{Builtin, Const, Span}; use crate::core::context::TypecheckContext; use crate::core::valuef::ValueF; diff --git a/dhall/src/core/valuef.rs b/dhall/src/core/valuef.rs index e5d0807..e9ac391 100644 --- a/dhall/src/core/valuef.rs +++ b/dhall/src/core/valuef.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use dhall_syntax::{ +use crate::syntax::{ Builtin, Const, ExprF, Integer, InterpolatedTextContents, Label, NaiveDouble, Natural, }; @@ -117,7 +117,7 @@ impl ValueF { .collect(), )), ValueF::Equivalence(x, y) => rc(ExprF::BinOp( - dhall_syntax::BinOp::Equivalence, + crate::syntax::BinOp::Equivalence, x.to_expr(opts), y.to_expr(opts), )), diff --git a/dhall/src/core/var.rs b/dhall/src/core/var.rs index 3795f10..f9d3478 100644 --- a/dhall/src/core/var.rs +++ b/dhall/src/core/var.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use dhall_syntax::{Label, V}; +use crate::syntax::{Label, V}; /// Stores a pair of variables: a normal one and one /// that corresponds to the alpha-normalized version of the first one. @@ -190,7 +190,7 @@ impl<T: Shift> Shift for std::cell::RefCell<T> { } } -impl<T: Shift, E: Clone> Shift for dhall_syntax::ExprF<T, E> { +impl<T: Shift, E: Clone> Shift for crate::syntax::ExprF<T, E> { fn shift(&self, delta: isize, var: &AlphaVar) -> Option<Self> { Some(self.traverse_ref_with_special_handling_of_binders( |v| Ok(v.shift(delta, var)?), @@ -222,7 +222,7 @@ where } } -impl<T: Shift> Shift for dhall_syntax::InterpolatedTextContents<T> { +impl<T: Shift> Shift for crate::syntax::InterpolatedTextContents<T> { fn shift(&self, delta: isize, var: &AlphaVar) -> Option<Self> { Some(self.traverse_ref(|x| Ok(x.shift(delta, var)?))?) } @@ -262,7 +262,7 @@ impl<S, T: Subst<S>> Subst<S> for std::cell::RefCell<T> { } } -impl<S: Shift, T: Subst<S>, E: Clone> Subst<S> for dhall_syntax::ExprF<T, E> { +impl<S: Shift, T: Subst<S>, E: Clone> Subst<S> for crate::syntax::ExprF<T, E> { fn subst_shift(&self, var: &AlphaVar, val: &S) -> Self { self.map_ref_with_special_handling_of_binders( |v| v.subst_shift(var, val), @@ -277,7 +277,7 @@ impl<S, T: Subst<S>> Subst<S> for Vec<T> { } } -impl<S, T: Subst<S>> Subst<S> for dhall_syntax::InterpolatedTextContents<T> { +impl<S, T: Subst<S>> Subst<S> for crate::syntax::InterpolatedTextContents<T> { fn subst_shift(&self, var: &AlphaVar, val: &S) -> Self { self.map_ref(|x| x.subst_shift(var, val)) } diff --git a/dhall/src/error/mod.rs b/dhall/src/error/mod.rs index e4baea0..1d58e6f 100644 --- a/dhall/src/error/mod.rs +++ b/dhall/src/error/mod.rs @@ -1,6 +1,6 @@ use std::io::Error as IOError; -use dhall_syntax::{BinOp, Import, Label, ParseError, Span}; +use crate::syntax::{BinOp, Import, Label, ParseError, Span}; use crate::core::context::TypecheckContext; use crate::core::value::Value; diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index ed4435a..66c6e5b 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -15,3 +15,7 @@ mod tests; pub mod core; pub mod error; pub mod phase; + +pub mod syntax { + pub use dhall_syntax::*; +} diff --git a/dhall/src/phase/binary.rs b/dhall/src/phase/binary.rs index 0639120..b1e7638 100644 --- a/dhall/src/phase/binary.rs +++ b/dhall/src/phase/binary.rs @@ -3,8 +3,8 @@ use serde_cbor::value::value as cbor; use std::iter::FromIterator; use std::vec; -use dhall_syntax::map::DupTreeMap; -use dhall_syntax::{ +use crate::syntax::map::DupTreeMap; +use crate::syntax::{ Expr, ExprF, FilePath, FilePrefix, Hash, Import, ImportLocation, ImportMode, Integer, InterpolatedText, Label, Natural, RawExpr, Scheme, Span, URL, V, @@ -32,7 +32,7 @@ pub fn rc<E>(x: RawExpr<E>) -> Expr<E> { fn cbor_value_to_dhall(data: &cbor::Value) -> Result<DecodedExpr, DecodeError> { use cbor::Value::*; - use dhall_syntax::{BinOp, Builtin, Const}; + use crate::syntax::{BinOp, Builtin, Const}; use ExprF::*; Ok(rc(match data { String(s) => match Builtin::parse(s) { @@ -350,7 +350,7 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result<DecodedExpr, DecodeError> { "import/type".to_owned(), ))?, }; - Import(dhall_syntax::Import { + Import(crate::syntax::Import { mode, hash, location, @@ -473,8 +473,8 @@ where S: serde::ser::Serializer, { use cbor::Value::{String, I64, U64}; - use dhall_syntax::Builtin; - use dhall_syntax::ExprF::*; + use crate::syntax::Builtin; + use crate::syntax::ExprF::*; use std::iter::once; use self::Serialize::{RecordMap, UnionMap}; @@ -548,7 +548,7 @@ where once(tag(4)).chain(once(null())).chain(xs.iter().map(expr)), ), TextLit(xs) => { - use dhall_syntax::InterpolatedTextContents::{Expr, Text}; + use crate::syntax::InterpolatedTextContents::{Expr, Text}; ser.collect_seq(once(tag(18)).chain(xs.iter().map(|x| match x { Expr(x) => expr(x), Text(x) => cbor(String(x.clone())), @@ -559,7 +559,7 @@ where UnionType(map) => ser_seq!(ser; tag(11), UnionMap(map)), Field(x, l) => ser_seq!(ser; tag(9), expr(x), label(l)), BinOp(op, x, y) => { - use dhall_syntax::BinOp::*; + use crate::syntax::BinOp::*; let op = match op { BoolOr => 0, BoolAnd => 1, diff --git a/dhall/src/phase/mod.rs b/dhall/src/phase/mod.rs index 337ce3d..918c4d0 100644 --- a/dhall/src/phase/mod.rs +++ b/dhall/src/phase/mod.rs @@ -1,7 +1,7 @@ use std::fmt::Display; use std::path::Path; -use dhall_syntax::{Builtin, Const, Expr}; +use crate::syntax::{Builtin, Const, Expr}; use crate::core::value::{ToExprOptions, Value}; use crate::core::valuef::ValueF; diff --git a/dhall/src/phase/normalize.rs b/dhall/src/phase/normalize.rs index b712027..3ed53f4 100644 --- a/dhall/src/phase/normalize.rs +++ b/dhall/src/phase/normalize.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; -use dhall_syntax::Const::Type; -use dhall_syntax::{ +use crate::syntax::Const::Type; +use crate::syntax::{ BinOp, Builtin, ExprF, InterpolatedText, InterpolatedTextContents, Label, NaiveDouble, }; @@ -47,7 +47,7 @@ macro_rules! make_closure { }}; (1 + $($rest:tt)*) => { ValueF::PartialExpr(ExprF::BinOp( - dhall_syntax::BinOp::NaturalPlus, + crate::syntax::BinOp::NaturalPlus, make_closure!($($rest)*), Value::from_valuef_and_type( ValueF::NaturalLit(1), @@ -62,7 +62,7 @@ macro_rules! make_closure { let tail = make_closure!($($tail)*); let list_type = tail.get_type_not_sort(); ValueF::PartialExpr(ExprF::BinOp( - dhall_syntax::BinOp::ListAppend, + crate::syntax::BinOp::ListAppend, ValueF::NEListLit(vec![head]) .into_value_with_type(list_type.clone()), tail, @@ -76,7 +76,7 @@ pub(crate) fn apply_builtin( args: Vec<Value>, ty: &Value, ) -> ValueF { - use dhall_syntax::Builtin::*; + use crate::syntax::Builtin::*; use ValueF::*; // Small helper enum diff --git a/dhall/src/phase/parse.rs b/dhall/src/phase/parse.rs index 540ceea..e277e54 100644 --- a/dhall/src/phase/parse.rs +++ b/dhall/src/phase/parse.rs @@ -2,7 +2,7 @@ use std::fs::File; use std::io::Read; use std::path::Path; -use dhall_syntax::parse_expr; +use crate::syntax::parse_expr; use crate::error::Error; use crate::phase::resolve::ImportRoot; diff --git a/dhall/src/phase/resolve.rs b/dhall/src/phase/resolve.rs index c302bfa..5920f82 100644 --- a/dhall/src/phase/resolve.rs +++ b/dhall/src/phase/resolve.rs @@ -3,9 +3,9 @@ use std::path::{Path, PathBuf}; use crate::error::{Error, ImportError}; use crate::phase::{Normalized, NormalizedExpr, Parsed, Resolved}; -use dhall_syntax::{FilePath, ImportLocation, URL}; +use crate::syntax::{FilePath, ImportLocation, URL}; -type Import = dhall_syntax::Import<NormalizedExpr>; +type Import = crate::syntax::Import<NormalizedExpr>; /// A root from which to resolve relative imports. #[derive(Debug, Clone, PartialEq, Eq)] @@ -24,8 +24,8 @@ fn resolve_import( import_stack: &ImportStack, ) -> Result<Normalized, ImportError> { use self::ImportRoot::*; - use dhall_syntax::FilePrefix::*; - use dhall_syntax::ImportLocation::*; + use crate::syntax::FilePrefix::*; + use crate::syntax::ImportLocation::*; let cwd = match root { LocalDir(cwd) => cwd, }; diff --git a/dhall/src/phase/typecheck.rs b/dhall/src/phase/typecheck.rs index ef8340d..9a41be9 100644 --- a/dhall/src/phase/typecheck.rs +++ b/dhall/src/phase/typecheck.rs @@ -1,7 +1,7 @@ use std::cmp::max; use std::collections::HashMap; -use dhall_syntax::{ +use crate::syntax::{ Builtin, Const, Expr, ExprF, InterpolatedTextContents, Label, RawExpr, Span, }; @@ -155,7 +155,7 @@ macro_rules! make_type { (Double) => { ExprF::Builtin(Builtin::Double) }; (Text) => { ExprF::Builtin(Builtin::Text) }; ($var:ident) => { - ExprF::Var(dhall_syntax::V(stringify!($var).into(), 0)) + ExprF::Var(crate::syntax::V(stringify!($var).into(), 0)) }; (Optional $ty:ident) => { ExprF::App( @@ -170,7 +170,7 @@ macro_rules! make_type { ) }; ({ $($label:ident : $ty:ident),* }) => {{ - let mut kts = dhall_syntax::map::DupTreeMap::new(); + let mut kts = crate::syntax::map::DupTreeMap::new(); $( kts.insert( Label::from(stringify!($label)), @@ -203,7 +203,7 @@ macro_rules! make_type { } fn type_of_builtin<E>(b: Builtin) -> Expr<E> { - use dhall_syntax::Builtin::*; + use crate::syntax::Builtin::*; rc(match b { Bool | Natural | Integer | Double | Text => make_type!(Type), List | Optional => make_type!( @@ -303,7 +303,7 @@ fn type_with( ctx: &TypecheckContext, e: Expr<Normalized>, ) -> Result<Value, TypeError> { - use dhall_syntax::ExprF::{Annot, Embed, Lam, Let, Pi, Var}; + use crate::syntax::ExprF::{Annot, Embed, Lam, Let, Pi, Var}; let span = e.span(); Ok(match e.as_ref() { @@ -362,10 +362,10 @@ fn type_last_layer( span: Span, ) -> Result<Value, TypeError> { use crate::error::TypeMessage::*; - use dhall_syntax::BinOp::*; - use dhall_syntax::Builtin::*; - use dhall_syntax::Const::Type; - use dhall_syntax::ExprF::*; + use crate::syntax::BinOp::*; + use crate::syntax::Builtin::*; + use crate::syntax::Const::Type; + use crate::syntax::ExprF::*; let mkerr = |msg: TypeMessage| Err(TypeError::new(ctx, msg)); /// Intermediary return type @@ -434,7 +434,7 @@ fn type_last_layer( } EmptyListLit(t) => { match &*t.as_whnf() { - ValueF::AppliedBuiltin(dhall_syntax::Builtin::List, args) + ValueF::AppliedBuiltin(crate::syntax::Builtin::List, args) if args.len() == 1 => {} _ => return mkerr(InvalidListType(t.clone())), } @@ -457,7 +457,7 @@ fn type_last_layer( return mkerr(InvalidListType(t)); } - RetTypeOnly(Value::from_builtin(dhall_syntax::Builtin::List).app(t)) + RetTypeOnly(Value::from_builtin(crate::syntax::Builtin::List).app(t)) } SomeLit(x) => { let t = x.get_type()?; @@ -466,7 +466,7 @@ fn type_last_layer( } RetTypeOnly( - Value::from_builtin(dhall_syntax::Builtin::Optional).app(t), + Value::from_builtin(crate::syntax::Builtin::Optional).app(t), ) } RecordType(kts) => RetWhole(tck_record_type( diff --git a/serde_dhall/src/lib.rs b/serde_dhall/src/lib.rs index d371d6d..91b47e5 100644 --- a/serde_dhall/src/lib.rs +++ b/serde_dhall/src/lib.rs @@ -123,7 +123,7 @@ pub use value::Value; // A Dhall value. pub mod value { use dhall::phase::{NormalizedExpr, Parsed, Typed}; - use dhall_syntax::Builtin; + use dhall::syntax::Builtin; use super::de::{Error, Result}; diff --git a/serde_dhall/src/serde.rs b/serde_dhall/src/serde.rs index 26708c1..2972ea2 100644 --- a/serde_dhall/src/serde.rs +++ b/serde_dhall/src/serde.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use dhall::phase::NormalizedExpr; -use dhall_syntax::ExprF; +use dhall::syntax::ExprF; use crate::de::{Deserialize, Error, Result}; use crate::Value; diff --git a/serde_dhall/src/static_type.rs b/serde_dhall/src/static_type.rs index 67a7bc4..1323aa3 100644 --- a/serde_dhall/src/static_type.rs +++ b/serde_dhall/src/static_type.rs @@ -1,4 +1,4 @@ -use dhall_syntax::{Builtin, Integer, Natural}; +use dhall::syntax::{Builtin, Integer, Natural}; use crate::Value; |