Skip to content

Commit 7ea5f6f

Browse files
Gabriella439mergify[bot]
authored andcommitted
Remove support for fusion (#1478)
* Remove support for fusion ... as standardized in dhall-lang/dhall-lang#792 * Update `dhall.cabal` to match the latest Prelude * Update `dhall-lang` ... and blacklist tests we don't support yet * Add missing files to `dhall.cabal`
1 parent b843cae commit 7ea5f6f

File tree

5 files changed

+22
-42
lines changed

5 files changed

+22
-42
lines changed

dhall/dhall-lang

Submodule dhall-lang updated 68 files

dhall/dhall.cabal

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Extra-Source-Files:
5151
dhall-lang/Prelude/JSON/null
5252
dhall-lang/Prelude/JSON/number
5353
dhall-lang/Prelude/JSON/object
54+
dhall-lang/Prelude/JSON/omitNullFields
5455
dhall-lang/Prelude/JSON/package.dhall
5556
dhall-lang/Prelude/JSON/render
5657
dhall-lang/Prelude/JSON/string
@@ -62,6 +63,7 @@ Extra-Source-Files:
6263
dhall-lang/Prelude/List/concat
6364
dhall-lang/Prelude/List/concatMap
6465
dhall-lang/Prelude/List/default
66+
dhall-lang/Prelude/List/drop
6567
dhall-lang/Prelude/List/empty
6668
dhall-lang/Prelude/List/filter
6769
dhall-lang/Prelude/List/fold
@@ -74,9 +76,11 @@ Extra-Source-Files:
7476
dhall-lang/Prelude/List/map
7577
dhall-lang/Prelude/List/null
7678
dhall-lang/Prelude/List/package.dhall
79+
dhall-lang/Prelude/List/partition
7780
dhall-lang/Prelude/List/replicate
7881
dhall-lang/Prelude/List/reverse
7982
dhall-lang/Prelude/List/shifted
83+
dhall-lang/Prelude/List/take
8084
dhall-lang/Prelude/List/unzip
8185
dhall-lang/Prelude/Location/package.dhall
8286
dhall-lang/Prelude/Location/Type
@@ -100,10 +104,15 @@ Extra-Source-Files:
100104
dhall-lang/Prelude/Natural/isZero
101105
dhall-lang/Prelude/Natural/lessThan
102106
dhall-lang/Prelude/Natural/lessThanEqual
107+
dhall-lang/Prelude/Natural/listMax
108+
dhall-lang/Prelude/Natural/listMin
109+
dhall-lang/Prelude/Natural/max
110+
dhall-lang/Prelude/Natural/min
103111
dhall-lang/Prelude/Natural/odd
104112
dhall-lang/Prelude/Natural/package.dhall
105113
dhall-lang/Prelude/Natural/product
106114
dhall-lang/Prelude/Natural/show
115+
dhall-lang/Prelude/Natural/sort
107116
dhall-lang/Prelude/Natural/subtract
108117
dhall-lang/Prelude/Natural/sum
109118
dhall-lang/Prelude/Natural/toDouble

dhall/src/Dhall/Eval.hs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,6 @@ data HLamInfo a
133133
-- ^ Don't store any information
134134
| Typed !Text (Val a)
135135
-- ^ Store the original name and type of the variable bound by the `Lam`
136-
| NaturalFoldCl (Val a)
137-
-- ^ The original function was a @Natural/fold@. We need to preserve this
138-
-- information in order to implement @Natural/{build,fold}@ fusion
139-
| ListFoldCl (Val a)
140-
-- ^ The original function was a @List/fold@. We need to preserve this
141-
-- information in order to implement @List/{build,fold}@ fusion
142-
| OptionalFoldCl (Val a)
143-
-- ^ The original function was an @Optional/fold@. We need to preserve this
144-
-- information in order to implement @Optional/{build,fold}@ fusion
145136
| NaturalSubtractZero
146137
-- ^ The original function was a @Natural/subtract 0@. We need to preserve
147138
-- this information in case the @Natural/subtract@ ends up not being fully
@@ -470,14 +461,12 @@ eval !env t0 =
470461
go acc m = go (vApp succ acc) (m - 1)
471462
in go zero (fromIntegral n :: Integer)
472463
n ->
473-
VHLam (NaturalFoldCl n) $ \natural ->
464+
VPrim $ \natural ->
474465
VPrim $ \succ ->
475466
VPrim $ \zero ->
476467
VNaturalFold n natural succ zero
477468
NaturalBuild ->
478469
VPrim $ \case
479-
VHLam (NaturalFoldCl x) _ ->
480-
x
481470
VPrimVar ->
482471
VNaturalBuild VPrimVar
483472
t -> t
@@ -580,8 +569,6 @@ eval !env t0 =
580569
ListBuild ->
581570
VPrim $ \a ->
582571
VPrim $ \case
583-
VHLam (ListFoldCl x) _ ->
584-
x
585572
VPrimVar ->
586573
VListBuild a VPrimVar
587574
t -> t
@@ -600,7 +587,7 @@ eval !env t0 =
600587
VHLam (Typed "nil" list) $ \nil ->
601588
foldr' (\x b -> cons `vApp` x `vApp` b) nil as
602589
as ->
603-
VHLam (ListFoldCl as) $ \t ->
590+
VPrim $ \t ->
604591
VPrim $ \c ->
605592
VPrim $ \n ->
606593
VListFold a as t c n
@@ -679,14 +666,13 @@ eval !env t0 =
679666
VHLam (Typed "none" optional) $ \_none ->
680667
some `vApp` t
681668
opt ->
682-
VHLam (OptionalFoldCl opt) $ \o ->
669+
VPrim $ \o ->
683670
VPrim $ \s ->
684671
VPrim $ \n ->
685672
VOptionalFold a opt o s n
686673
OptionalBuild ->
687674
VPrim $ \ ~a ->
688675
VPrim $ \case
689-
VHLam (OptionalFoldCl x) _ -> x
690676
VPrimVar -> VOptionalBuild a VPrimVar
691677
t -> t
692678
`vApp` VOptional a
@@ -1014,9 +1000,6 @@ quote !env !t0 =
10141000
case i of
10151001
Typed (fresh -> (x, v)) a -> Lam x (quote env a) (quoteBind x (t v))
10161002
Prim -> quote env (t VPrimVar)
1017-
NaturalFoldCl{} -> quote env (t VPrimVar)
1018-
ListFoldCl{} -> quote env (t VPrimVar)
1019-
OptionalFoldCl{} -> quote env (t VPrimVar)
10201003
NaturalSubtractZero -> App NaturalSubtract (NaturalLit 0)
10211004

10221005
VPi a (freshClosure -> (x, v, b)) ->

dhall/src/Dhall/Normalize.hs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,6 @@ normalizeWithM ctx e0 = loop (Syntax.denote e0)
567567
loop b₂
568568
_ -> do
569569
case App f' a' of
570-
-- build/fold fusion for `List`
571-
App (App ListBuild _) (App (App ListFold _) e') -> loop e'
572-
573570
App NaturalFold (NaturalLit n) -> do
574571
let natural = Var (V "natural" 0)
575572
let go 0 x = x
@@ -584,12 +581,6 @@ normalizeWithM ctx e0 = loop (Syntax.denote e0)
584581
natural
585582
n')))
586583

587-
-- build/fold fusion for `Natural`
588-
App NaturalBuild (App NaturalFold e') -> loop e'
589-
590-
-- build/fold fusion for `Optional`
591-
App (App OptionalBuild _) (App (App OptionalFold _) e') -> loop e'
592-
593584
App (App (App (App NaturalFold (NaturalLit n0)) t) succ') zero -> do
594585
t' <- loop t
595586
if boundedType t' then strict else lazy
@@ -1056,16 +1047,6 @@ isNormalized e0 = loop (Syntax.denote e0)
10561047
Pi _ a b -> loop a && loop b
10571048
App f a -> loop f && loop a && case App f a of
10581049
App (Lam _ _ _) _ -> False
1059-
1060-
-- build/fold fusion for `List`
1061-
App (App ListBuild _) (App (App ListFold _) _) -> False
1062-
1063-
-- build/fold fusion for `Natural`
1064-
App NaturalBuild (App NaturalFold _) -> False
1065-
1066-
-- build/fold fusion for `Optional`
1067-
App (App OptionalBuild _) (App (App OptionalFold _) _) -> False
1068-
10691050
App (App (App (App NaturalFold (NaturalLit _)) _) _) _ -> False
10701051
App NaturalFold (NaturalLit _) -> False
10711052
App NaturalBuild _ -> False

dhall/tests/Dhall/Test/Parser.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ shouldParse path = do
122122
let expectedFailures =
123123
-- This is a bug created by a parsing performance
124124
-- improvement
125-
[ parseDirectory </> "success/unit/MergeParenAnnotation" ]
125+
[ parseDirectory </> "success/unit/MergeParenAnnotation"
126+
127+
-- https://github.com/dhall-lang/dhall-haskell/issues/1454
128+
, parseDirectory </> "success/preferMissingNoSpaces"
129+
, parseDirectory </> "success/missingInParentheses"
130+
]
126131

127132
let pathString = Text.unpack path
128133

@@ -131,7 +136,9 @@ shouldParse path = do
131136

132137
encoded <- ByteString.Lazy.readFile (pathString <> "B.dhallb")
133138

134-
expression <- Core.throws (Parser.exprFromText mempty text)
139+
expression <- case Parser.exprFromText mempty text of
140+
Left exception -> Tasty.HUnit.assertFailure (show exception)
141+
Right expression -> return expression
135142

136143
let bytes = Binary.encodeExpression (Core.denote expression)
137144

0 commit comments

Comments
 (0)