From df31616e170235bd6e82ee6385d7ce4f81824426 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 2 May 2019 21:24:10 +0200 Subject: Update dhall-lang submodule --- dhall-lang | 2 +- dhall/src/normalize.rs | 41 +++++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/dhall-lang b/dhall-lang index f4a0a2d..588741c 160000 --- a/dhall-lang +++ b/dhall-lang @@ -1 +1 @@ -Subproject commit f4a0a2dd3b55c3191a3ddac941387607699c3dc7 +Subproject commit 588741c181225bb82eddd325ea1caf105d4745ce diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index f991a2e..9efce7d 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -1258,17 +1258,22 @@ fn normalize_whnf(ctx: NormalizationContext, expr: InputSubExpr) -> Value { }) .collect(), ), - ExprF::TextLit(elts) => Value::TextLit( - elts.iter() - .map(|contents| { - use InterpolatedTextContents::{Expr, Text}; - match contents { - Expr(n) => Expr(Thunk::new(ctx.clone(), n.clone())), - Text(s) => Text(s.clone()), - } + ExprF::TextLit(elts) => { + use InterpolatedTextContents::{Expr, Text}; + let elts: Vec<_> = elts + .iter() + .map(|contents| match contents { + Expr(n) => Expr(Thunk::new(ctx.clone(), n.clone())), + Text(s) => Text(s.clone()), }) - .collect(), - ), + .collect(); + if elts.len() == 1 { + if let Expr(th) = &elts[0] { + return th.normalize_whnf().clone(); + } + } + Value::TextLit(elts) + } ExprF::BoolIf(b, e1, e2) => { let b = normalize_whnf(ctx.clone(), b.clone()); match b { @@ -1350,6 +1355,14 @@ fn normalize_last_layer(expr: ExprF) -> Value { } ExprF::BinOp(TextAppend, TextLit(x), y) if x.is_empty() => y, ExprF::BinOp(TextAppend, x, TextLit(y)) if y.is_empty() => x, + ExprF::BinOp(TextAppend, TextLit(mut x), y) => { + x.push(InterpolatedTextContents::Expr(Thunk::from_whnf(y))); + TextLit(x) + } + ExprF::BinOp(TextAppend, x, TextLit(mut y)) => { + y.insert(0, InterpolatedTextContents::Expr(Thunk::from_whnf(x))); + TextLit(y) + } ExprF::Field(UnionType(kts), l) => UnionConstructor(l, kts), ExprF::Field(RecordLit(mut kvs), l) => match kvs.remove(&l) { @@ -1410,7 +1423,6 @@ mod spec_tests { // norm!(success_haskell_tutorial_prefer_0, "haskell-tutorial/prefer/0"); norm!(success_haskell_tutorial_projection_0, "haskell-tutorial/projection/0"); - norm!(success_prelude_Bool_and_0, "prelude/Bool/and/0"); norm!(success_prelude_Bool_and_1, "prelude/Bool/and/1"); norm!(success_prelude_Bool_build_0, "prelude/Bool/build/0"); @@ -1538,10 +1550,8 @@ mod spec_tests { // norm!(success_prelude_Text_concatSep_1, "prelude/Text/concatSep/1"); // norm!(success_prelude_Text_show_0, "prelude/Text/show/0"); // norm!(success_prelude_Text_show_1, "prelude/Text/show/1"); - - - // norm!(success_remoteSystems, "remoteSystems"); + // norm!(success_simple_doubleShow, "simple/doubleShow"); // norm!(success_simple_integerShow, "simple/integerShow"); // norm!(success_simple_integerToDouble, "simple/integerToDouble"); @@ -1672,8 +1682,7 @@ mod spec_tests { norm!(success_unit_OperatorPlusOneAndOne, "unit/OperatorPlusOneAndOne"); norm!(success_unit_OperatorPlusRhsZero, "unit/OperatorPlusRhsZero"); norm!(success_unit_OperatorTextConcatenateLhsEmpty, "unit/OperatorTextConcatenateLhsEmpty"); - norm!(success_unit_OperatorTextConcatenateNormalizeArguments, "unit/OperatorTextConcatenateNormalizeArguments"); - norm!(success_unit_OperatorTextConcatenateRhsEmpty, "unit/OperatorTextConcatenateRhsEmpty"); + norm!(success_unit_OperatorTextConcatenateLhsNonEmpty, "unit/OperatorTextConcatenateLhsNonEmpty"); norm!(success_unit_OperatorTextConcatenateTextText, "unit/OperatorTextConcatenateTextText"); norm!(success_unit_OperatorTimesLhsOne, "unit/OperatorTimesLhsOne"); norm!(success_unit_OperatorTimesLhsZero, "unit/OperatorTimesLhsZero"); -- cgit v1.2.3