diff options
author | Nadrieril | 2019-08-06 22:36:43 +0200 |
---|---|---|
committer | Nadrieril | 2019-08-06 22:36:43 +0200 |
commit | 705433487da3cd3b4517fcf74b0497c76dbb4080 (patch) | |
tree | 32a55f2824cd24d90211873c5bda42a14ae4824f /dhall/src/phase/normalize.rs | |
parent | 0a1cf5554e8c06d05d24bdcdcf1eb71f0ac6d8f2 (diff) |
Prepare for https://github.com/dhall-lang/dhall-lang/pull/630
Diffstat (limited to '')
-rw-r--r-- | dhall/src/phase/normalize.rs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/dhall/src/phase/normalize.rs b/dhall/src/phase/normalize.rs index 4bc0f04..2e9f258 100644 --- a/dhall/src/phase/normalize.rs +++ b/dhall/src/phase/normalize.rs @@ -622,9 +622,9 @@ fn apply_binop<'a>(o: BinOp, x: &'a Thunk, y: &'a Thunk) -> Option<Ret<'a>> { pub fn normalize_one_layer(expr: ExprF<Thunk, X>) -> Value { use Value::{ - BoolLit, DoubleLit, EmptyListLit, IntegerLit, Lam, NEListLit, - NEOptionalLit, NaturalLit, Pi, RecordLit, RecordType, TextLit, - UnionConstructor, UnionLit, UnionType, + AppliedBuiltin, BoolLit, DoubleLit, EmptyListLit, IntegerLit, Lam, + NEListLit, NEOptionalLit, NaturalLit, Pi, RecordLit, RecordType, + TextLit, UnionConstructor, UnionLit, UnionType, }; let ret = match expr { @@ -651,8 +651,20 @@ pub fn normalize_one_layer(expr: ExprF<Thunk, X>) -> Value { ExprF::IntegerLit(n) => Ret::Value(IntegerLit(n)), ExprF::DoubleLit(n) => Ret::Value(DoubleLit(n)), ExprF::SomeLit(e) => Ret::Value(NEOptionalLit(e)), - ExprF::EmptyListLit(t) => { - Ret::Value(EmptyListLit(TypeThunk::from_thunk(t))) + ExprF::EmptyListLit(ref t) => { + // Check if the type is of the form `List x` + let t_borrow = t.as_value(); + match &*t_borrow { + AppliedBuiltin(Builtin::List, args) if args.len() == 1 => { + Ret::Value(EmptyListLit(TypeThunk::from_thunk( + args[0].clone(), + ))) + } + _ => { + drop(t_borrow); + Ret::Expr(expr) + } + } } ExprF::NEListLit(elts) => { Ret::Value(NEListLit(elts.into_iter().collect())) |