dhall 1.21.0 → 1.22.0
raw patch · 678 files changed
+4323/−3060 lines, 678 filesdep +foldldep +turtlebinary-addedPVP ok
version bump matches the API change (PVP)
Dependencies added: foldl, turtle
API changes (from Hackage documentation)
Files
- CHANGELOG.md +29/−0
- benchmark/dhall-command/Main.hs +1/−1
- benchmark/examples/normalize/ChurchEval.dhall +22/−0
- benchmark/examples/normalize/FunCompose.dhall +18/−0
- benchmark/examples/normalize/ListBench.dhall +75/−0
- benchmark/examples/normalize/ListBenchAlt.dhall +45/−0
- benchmark/parser/Main.hs +1/−1
- dhall-lang/Prelude/Bool/package.dhall +16/−8
- dhall-lang/Prelude/Double/package.dhall +4/−1
- dhall-lang/Prelude/Function/package.dhall +4/−1
- dhall-lang/Prelude/Integer/package.dhall +7/−1
- dhall-lang/Prelude/JSON/package.dhall +7/−1
- dhall-lang/Prelude/List/package.dhall +38/−19
- dhall-lang/Prelude/Natural/package.dhall +22/−11
- dhall-lang/Prelude/Optional/package.dhall +26/−13
- dhall-lang/Prelude/Text/concatMapSep +27/−33
- dhall-lang/Prelude/Text/concatSep +25/−31
- dhall-lang/Prelude/Text/package.dhall +10/−5
- dhall-lang/Prelude/package.dhall +18/−9
- dhall-lang/tests/import/data/cycle.dhall +1/−0
- dhall-lang/tests/import/data/example.txt +1/−0
- dhall-lang/tests/import/data/referentiallyOpaque.dhall +20/−0
- dhall-lang/tests/import/success/alternativeHashMismatchA.dhall +1/−0
- dhall-lang/tests/import/success/alternativeHashMismatchB.dhall +1/−0
- dhall-lang/tests/import/success/alternativeParseErrorA.dhall +1/−0
- dhall-lang/tests/import/success/alternativeParseErrorB.dhall +1/−0
- dhall-lang/tests/normalization/success/haskell-tutorial/access/1B.dhall +1/−1
- dhall-lang/tests/normalization/success/multiline/escapeA.dhall +0/−9
- dhall-lang/tests/normalization/success/multiline/escapeB.dhall +0/−1
- dhall-lang/tests/normalization/success/multiline/hangingIndentA.dhall +0/−15
- dhall-lang/tests/normalization/success/multiline/hangingIndentB.dhall +0/−1
- dhall-lang/tests/normalization/success/multiline/interestingA.dhall +0/−7
- dhall-lang/tests/normalization/success/multiline/interestingB.dhall +0/−1
- dhall-lang/tests/normalization/success/multiline/interiorIndentA.dhall +0/−16
- dhall-lang/tests/normalization/success/multiline/interiorIndentB.dhall +0/−1
- dhall-lang/tests/normalization/success/multiline/interpolationA.dhall +0/−9
- dhall-lang/tests/normalization/success/multiline/interpolationB.dhall +0/−1
- dhall-lang/tests/normalization/success/multiline/preserveCommentA.dhall +0/−8
- dhall-lang/tests/normalization/success/multiline/preserveCommentB.dhall +0/−1
- dhall-lang/tests/normalization/success/multiline/singleLineA.dhall +0/−6
- dhall-lang/tests/normalization/success/multiline/singleLineB.dhall +0/−1
- dhall-lang/tests/normalization/success/multiline/twoLinesA.dhall +0/−7
- dhall-lang/tests/normalization/success/multiline/twoLinesB.dhall +0/−1
- dhall-lang/tests/normalization/success/prelude/Bool/and/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/and/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/build/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/build/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/even/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/even/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/even/2A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/even/3A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/fold/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/fold/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/not/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/not/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/odd/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/odd/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/odd/2A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/odd/3A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/or/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/or/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/show/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Bool/show/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Double/show/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Double/show/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Integer/show/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Integer/show/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Integer/toDouble/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Integer/toDouble/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/all/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/all/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/any/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/any/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/build/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/build/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/concat/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/concat/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/concatMap/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/concatMap/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/filter/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/filter/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/fold/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/fold/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/fold/2A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/generate/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/generate/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/head/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/head/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/indexed/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/indexed/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/iterate/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/iterate/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/last/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/last/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/length/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/length/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/map/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/map/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/null/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/null/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/replicate/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/replicate/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/reverse/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/reverse/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/shifted/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/shifted/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/unzip/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/List/unzip/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/build/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/build/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/enumerate/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/enumerate/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/even/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/even/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/fold/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/fold/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/fold/2A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/fold/2B.dhall +4/−1
- dhall-lang/tests/normalization/success/prelude/Natural/isZero/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/isZero/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/odd/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/odd/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/product/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/product/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/show/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/show/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/sum/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/sum/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/toDouble/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/toDouble/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/toInteger/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Natural/toInteger/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/all/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/all/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/any/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/any/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/build/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/build/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/concat/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/concat/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/concat/2A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/filter/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/filter/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/fold/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/fold/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/head/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/head/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/head/2A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/last/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/last/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/last/2A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/length/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/length/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/map/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/map/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/null/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/null/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/toList/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/toList/0B.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/toList/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/unzip/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Optional/unzip/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Text/concat/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Text/concat/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Text/concatMap/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Text/concatMap/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Text/concatMapSep/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Text/concatMapSep/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Text/concatSep/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Text/concatSep/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Text/show/0A.dhall +1/−1
- dhall-lang/tests/normalization/success/prelude/Text/show/1A.dhall +1/−1
- dhall-lang/tests/normalization/success/remoteSystemsA.dhall +2/−2
- dhall-lang/tests/normalization/success/remoteSystemsB.dhall +104/−147
- dhall-lang/tests/normalization/success/simple/doubleShowB.dhall +10/−5
- dhall-lang/tests/normalization/success/simple/enumA.dhall +8/−0
- dhall-lang/tests/normalization/success/simple/enumB.dhall +1/−0
- dhall-lang/tests/normalization/success/simple/listBuildB.dhall +2/−2
- dhall-lang/tests/normalization/success/simple/optionalBuildB.dhall +4/−4
- dhall-lang/tests/normalization/success/simple/optionalBuildFoldB.dhall +1/−1
- dhall-lang/tests/normalization/success/simplifications/andB.dhall +10/−5
- dhall-lang/tests/normalization/success/simplifications/eqB.dhall +6/−3
- dhall-lang/tests/normalization/success/simplifications/ifThenElseB.dhall +1/−3
- dhall-lang/tests/normalization/success/simplifications/neB.dhall +6/−3
- dhall-lang/tests/normalization/success/simplifications/orB.dhall +10/−5
- dhall-lang/tests/normalization/success/unit/BoolA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/BoolB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/DoubleA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/DoubleB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/DoubleLiteralA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/DoubleLiteralB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/DoubleShowA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/DoubleShowB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/DoubleShowValueA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/DoubleShowValueB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/EmptyAlternativeA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/EmptyAlternativeB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionApplicationCaptureA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionApplicationCaptureB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionApplicationNoSubstituteA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionApplicationNoSubstituteB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionApplicationNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionApplicationNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionApplicationSubstituteA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionApplicationSubstituteB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionTypeNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/FunctionTypeNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IfAlternativesIdenticalA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IfAlternativesIdenticalB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IfFalseA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IfFalseB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IfNormalizePredicateAndBranchesA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IfNormalizePredicateAndBranchesB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IfTrivialA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IfTrivialB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IfTrueA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IfTrueB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerNegativeA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerNegativeB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerPositiveA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerPositiveB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerShow-12A.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerShow-12B.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerShow12A.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerShow12B.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerShowA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerShowB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerToDouble-12A.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerToDouble-12B.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerToDouble12A.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerToDouble12B.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerToDoubleA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/IntegerToDoubleB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/KindA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/KindB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/LetA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/LetB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/LetWithTypeA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/LetWithTypeB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListBuildA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListBuildB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListBuildFoldFusionA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListBuildFoldFusionB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListBuildImplementationA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListBuildImplementationB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListFoldA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListFoldB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListFoldEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListFoldEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListFoldOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListFoldOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListHeadA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListHeadB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListHeadEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListHeadEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListHeadOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListHeadOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListIndexedA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListIndexedB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListIndexedEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListIndexedEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListIndexedOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListIndexedOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLastA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLastB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLastEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLastEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLastOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLastOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLengthA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLengthB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLengthEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLengthEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLengthOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListLengthOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListNormalizeElementsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListNormalizeElementsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListNormalizeTypeAnnotationA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListNormalizeTypeAnnotationB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListReverseA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListReverseB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListReverseEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListReverseEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListReverseTwoA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/ListReverseTwoB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/MergeA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/MergeB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/MergeEmptyAlternativeA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/MergeEmptyAlternativeB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/MergeNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/MergeNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/MergeWithTypeA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/MergeWithTypeB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/MergeWithTypeNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/MergeWithTypeNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalBuildA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalBuildB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalBuildFoldFusionA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalBuildFoldFusionB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalBuildImplementationA.dhall +2/−0
- dhall-lang/tests/normalization/success/unit/NaturalBuildImplementationB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalEvenA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalEvenB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalEvenOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalEvenOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalEvenZeroA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalEvenZeroB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalFoldA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalFoldB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalFoldOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalFoldOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalFoldZeroA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalFoldZeroB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalIsZeroA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalIsZeroB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalIsZeroOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalIsZeroOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalIsZeroZeroA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalIsZeroZeroB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalLiteralA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalLiteralB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalOddA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalOddB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalOddOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalOddOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalOddZeroA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalOddZeroB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalShowA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalShowB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalShowOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalShowOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalToIntegerA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalToIntegerB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalToIntegerOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NaturalToIntegerOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NoneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NoneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NoneNaturalA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/NoneNaturalB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndEquivalentArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndEquivalentArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndLhsFalseA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndLhsFalseB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndLhsTrueA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndLhsTrueB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndRhsFalseA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndRhsFalseB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndRhsTrueA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorAndRhsTrueB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorEqualEquivalentArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorEqualEquivalentArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorEqualLhsTrueA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorEqualLhsTrueB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorEqualNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorEqualNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorEqualRhsTrueA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorEqualRhsTrueB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorListConcatenateLhsEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorListConcatenateLhsEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorListConcatenateListListA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorListConcatenateListListB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorListConcatenateNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorListConcatenateNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorListConcatenateRhsEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorListConcatenateRhsEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorNotEqualEquivalentArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorNotEqualEquivalentArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorNotEqualLhsFalseA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorNotEqualLhsFalseB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorNotEqualNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorNotEqualNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorNotEqualRhsFalseA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorNotEqualRhsFalseB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrEquivalentArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrEquivalentArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrLhsFalseA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrLhsFalseB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrLhsTrueA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrLhsTrueB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrRhsFalseA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrRhsFalseB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrRhsTrueA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorOrRhsTrueB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorPlusLhsZeroA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorPlusLhsZeroB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorPlusNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorPlusNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorPlusOneAndOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorPlusOneAndOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorPlusRhsZeroA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorPlusRhsZeroB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTextConcatenateLhsEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTextConcatenateLhsEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTextConcatenateLhsNonEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTextConcatenateLhsNonEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTextConcatenateTextTextA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTextConcatenateTextTextB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesLhsOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesLhsOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesLhsZeroA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesLhsZeroB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesRhsOneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesRhsOneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesRhsZeroA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesRhsZeroB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesTwoAndTwoA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OperatorTimesTwoAndTwoB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalBuildA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalBuildB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalBuildFoldFusionA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalBuildFoldFusionB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalBuildImplementationA.dhall +3/−0
- dhall-lang/tests/normalization/success/unit/OptionalBuildImplementationB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalFoldA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalFoldB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalFoldNoneA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalFoldNoneB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalFoldSomeA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/OptionalFoldSomeB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordProjectionA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordProjectionB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordProjectionEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordProjectionEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordProjectionNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordProjectionNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordSelectionA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordSelectionB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordSelectionNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordSelectionNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordTypeA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordTypeB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordTypeEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecordTypeEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordMergeCollisionA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordMergeCollisionB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordMergeLhsEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordMergeLhsEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordMergeNoCollisionA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordMergeNoCollisionB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordMergeNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordMergeNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordMergeRhsEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordMergeRhsEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeCollisionA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeCollisionB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeLhsEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeLhsEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeNoCollisionA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeNoCollisionB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeRhsEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeRhsEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeSortsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RecursiveRecordTypeMergeSortsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RightBiasedRecordMergeCollisionA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RightBiasedRecordMergeCollisionB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RightBiasedRecordMergeLhsEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RightBiasedRecordMergeLhsEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RightBiasedRecordMergeNoCollisionA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RightBiasedRecordMergeNoCollisionB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RightBiasedRecordMergeNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RightBiasedRecordMergeNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RightBiasedRecordMergeRhsEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/RightBiasedRecordMergeRhsEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/SomeNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/SomeNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/SortA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/SortB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextInterpolateA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextInterpolateB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextLiteralA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextLiteralB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextNormalizeInterpolationsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextNormalizeInterpolationsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextShowA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextShowAllEscapesA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextShowAllEscapesB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TextShowB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TrueA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TrueB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TypeA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TypeAnnotationA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TypeAnnotationB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/TypeB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionNormalizeAlternativesA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionNormalizeAlternativesB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionProjectConstructorA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionProjectConstructorB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionSortAlternativesA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionSortAlternativesB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionTypeA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionTypeB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionTypeEmptyA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionTypeEmptyB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionTypeNormalizeArgumentsA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/UnionTypeNormalizeArgumentsB.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/VariableA.dhall +1/−0
- dhall-lang/tests/normalization/success/unit/VariableB.dhall +1/−0
- dhall-lang/tests/parser/failure/boundBuiltins.dhall +6/−0
- dhall-lang/tests/parser/failure/builtinWithIndex.dhall +1/−0
- dhall-lang/tests/parser/failure/fSomeX.dhall +1/−0
- dhall-lang/tests/parser/failure/spaceAfterListAppend.dhall +0/−2
- dhall-lang/tests/parser/success/asTextA.dhall +0/−1
- dhall-lang/tests/parser/success/asTextB.dhallb +0/−1
- dhall-lang/tests/parser/success/builtinNameAsFieldA.dhall +3/−0
- dhall-lang/tests/parser/success/builtinNameAsFieldB.dhallb binary
- dhall-lang/tests/parser/success/doubleQuotedStringA.dhall +0/−1
- dhall-lang/tests/parser/success/doubleQuotedStringB.dhallb +0/−1
- dhall-lang/tests/parser/success/environmentVariablesA.dhall +0/−5
- dhall-lang/tests/parser/success/environmentVariablesB.dhallb binary
- dhall-lang/tests/parser/success/escapedDoubleQuotedStringA.dhall +0/−1
- dhall-lang/tests/parser/success/escapedDoubleQuotedStringB.dhallb +0/−2
- dhall-lang/tests/parser/success/escapedSingleQuotedStringA.dhall +0/−4
- dhall-lang/tests/parser/success/escapedSingleQuotedStringB.dhallb +0/−2
- dhall-lang/tests/parser/success/forallB.dhallb binary
- dhall-lang/tests/parser/success/import/asTextA.dhall +1/−0
- dhall-lang/tests/parser/success/import/asTextB.dhallb +1/−0
- dhall-lang/tests/parser/success/import/environmentVariablesA.dhall +5/−0
- dhall-lang/tests/parser/success/import/environmentVariablesB.dhallb binary
- dhall-lang/tests/parser/success/import/hashA.dhall +1/−0
- dhall-lang/tests/parser/success/import/hashB.dhallb binary
- dhall-lang/tests/parser/success/import/importAltA.dhall +1/−0
- dhall-lang/tests/parser/success/import/importAltB.dhallb binary
- dhall-lang/tests/parser/success/import/parenthesizeUsingA.dhall +1/−0
- dhall-lang/tests/parser/success/import/parenthesizeUsingB.dhallb binary
- dhall-lang/tests/parser/success/import/pathTerminationA.dhall +3/−0
- dhall-lang/tests/parser/success/import/pathTerminationB.dhallb binary
- dhall-lang/tests/parser/success/import/pathsA.dhall +5/−0
- dhall-lang/tests/parser/success/import/pathsB.dhallb binary
- dhall-lang/tests/parser/success/import/quotedPathsA.dhall +3/−0
- dhall-lang/tests/parser/success/import/quotedPathsB.dhallb binary
- dhall-lang/tests/parser/success/import/unicodePathsA.dhall +1/−0
- dhall-lang/tests/parser/success/import/unicodePathsB.dhallb binary
- dhall-lang/tests/parser/success/import/urlsA.dhall +14/−0
- dhall-lang/tests/parser/success/import/urlsB.dhallb binary
- dhall-lang/tests/parser/success/importAltA.dhall +0/−1
- dhall-lang/tests/parser/success/importAltB.dhallb binary
- dhall-lang/tests/parser/success/interpolatedDoubleQuotedStringA.dhall +0/−1
- dhall-lang/tests/parser/success/interpolatedDoubleQuotedStringB.dhallb binary
- dhall-lang/tests/parser/success/interpolatedSingleQuotedStringA.dhall +0/−4
- dhall-lang/tests/parser/success/interpolatedSingleQuotedStringB.dhallb binary
- dhall-lang/tests/parser/success/labelB.dhallb binary
- dhall-lang/tests/parser/success/lambdaB.dhallb binary
- dhall-lang/tests/parser/success/largeExpressionA.dhall +17/−17
- dhall-lang/tests/parser/success/largeExpressionB.dhallb binary
- dhall-lang/tests/parser/success/letB.dhallb binary
- dhall-lang/tests/parser/success/mergeB.dhallb binary
- dhall-lang/tests/parser/success/mergeXYZA.dhall +1/−0
- dhall-lang/tests/parser/success/mergeXYZB.dhallb binary
- dhall-lang/tests/parser/success/multiletB.dhallb binary
- dhall-lang/tests/parser/success/operatorsA.dhall +2/−1
- dhall-lang/tests/parser/success/operatorsB.dhallb binary
- dhall-lang/tests/parser/success/parenthesizeUsingA.dhall +0/−1
- dhall-lang/tests/parser/success/parenthesizeUsingB.dhallb binary
- dhall-lang/tests/parser/success/pathTerminationA.dhall +0/−3
- dhall-lang/tests/parser/success/pathTerminationB.dhallb binary
- dhall-lang/tests/parser/success/pathsA.dhall +0/−5
- dhall-lang/tests/parser/success/pathsB.dhallb binary
- dhall-lang/tests/parser/success/quotedBoundVariableA.dhall +1/−0
- dhall-lang/tests/parser/success/quotedBoundVariableB.dhallb binary
- dhall-lang/tests/parser/success/quotedLabelB.dhallb binary
- dhall-lang/tests/parser/success/quotedPathsA.dhall +0/−3
- dhall-lang/tests/parser/success/quotedPathsB.dhallb binary
- dhall-lang/tests/parser/success/reservedPrefixB.dhallb binary
- dhall-lang/tests/parser/success/singleQuotedStringA.dhall +0/−4
- dhall-lang/tests/parser/success/singleQuotedStringB.dhallb +0/−2
- dhall-lang/tests/parser/success/someXYZA.dhall +6/−0
- dhall-lang/tests/parser/success/someXYZB.dhallb binary
- dhall-lang/tests/parser/success/spaceAfterListAppendA.dhall +11/−0
- dhall-lang/tests/parser/success/spaceAfterListAppendB.dhallb binary
- dhall-lang/tests/parser/success/templateA.dhall +0/−13
- dhall-lang/tests/parser/success/templateB.dhallb binary
- dhall-lang/tests/parser/success/text/doubleQuotedStringA.dhall +1/−0
- dhall-lang/tests/parser/success/text/doubleQuotedStringB.dhallb +1/−0
- dhall-lang/tests/parser/success/text/escapeA.dhall +9/−0
- dhall-lang/tests/parser/success/text/escapeB.dhallb +5/−0
- dhall-lang/tests/parser/success/text/escapedDoubleQuotedStringA.dhall +1/−0
- dhall-lang/tests/parser/success/text/escapedDoubleQuotedStringB.dhallb +2/−0
- dhall-lang/tests/parser/success/text/escapedSingleQuotedStringA.dhall +4/−0
- dhall-lang/tests/parser/success/text/escapedSingleQuotedStringB.dhallb +2/−0
- dhall-lang/tests/parser/success/text/interestingA.dhall +7/−0
- dhall-lang/tests/parser/success/text/interestingB.dhallb binary
- dhall-lang/tests/parser/success/text/interiorIndentA.dhall +16/−0
- dhall-lang/tests/parser/success/text/interiorIndentB.dhallb +2/−0
- dhall-lang/tests/parser/success/text/interpolatedDoubleQuotedStringA.dhall +1/−0
- dhall-lang/tests/parser/success/text/interpolatedDoubleQuotedStringB.dhallb binary
- dhall-lang/tests/parser/success/text/interpolatedSingleQuotedStringA.dhall +4/−0
- dhall-lang/tests/parser/success/text/interpolatedSingleQuotedStringB.dhallb binary
- dhall-lang/tests/parser/success/text/interpolationA.dhall +9/−0
- dhall-lang/tests/parser/success/text/interpolationB.dhallb binary
- dhall-lang/tests/parser/success/text/preserveCommentA.dhall +8/−0
- dhall-lang/tests/parser/success/text/preserveCommentB.dhallb +2/−0
- dhall-lang/tests/parser/success/text/singleLineA.dhall +6/−0
- dhall-lang/tests/parser/success/text/singleLineB.dhallb +1/−0
- dhall-lang/tests/parser/success/text/singleQuotedStringA.dhall +4/−0
- dhall-lang/tests/parser/success/text/singleQuotedStringB.dhallb +2/−0
- dhall-lang/tests/parser/success/text/templateA.dhall +13/−0
- dhall-lang/tests/parser/success/text/templateB.dhallb binary
- dhall-lang/tests/parser/success/text/twoLinesA.dhall +7/−0
- dhall-lang/tests/parser/success/text/twoLinesB.dhallb +2/−0
- dhall-lang/tests/parser/success/text/unicodeDoubleQuotedStringA.dhall +1/−0
- dhall-lang/tests/parser/success/text/unicodeDoubleQuotedStringB.dhallb +1/−0
- dhall-lang/tests/parser/success/unicodeDoubleQuotedStringA.dhall +0/−1
- dhall-lang/tests/parser/success/unicodeDoubleQuotedStringB.dhallb +0/−1
- dhall-lang/tests/parser/success/unicodePathsA.dhall +0/−1
- dhall-lang/tests/parser/success/unicodePathsB.dhallb binary
- dhall-lang/tests/parser/success/urlsA.dhall +0/−12
- dhall-lang/tests/parser/success/urlsB.dhallb binary
- dhall-lang/tests/typecheck/success/prelude/Monoid/00A.dhall +1/−1
- dhall-lang/tests/typecheck/success/prelude/Monoid/01A.dhall +1/−1
- dhall-lang/tests/typecheck/success/prelude/Monoid/02A.dhall +1/−1
- dhall-lang/tests/typecheck/success/prelude/Monoid/03A.dhall +1/−1
- dhall-lang/tests/typecheck/success/prelude/Monoid/04A.dhall +1/−1
- dhall-lang/tests/typecheck/success/prelude/Monoid/05A.dhall +1/−1
- dhall-lang/tests/typecheck/success/prelude/Monoid/06A.dhall +1/−1
- dhall-lang/tests/typecheck/success/prelude/Monoid/07A.dhall +1/−1
- dhall-lang/tests/typecheck/success/prelude/Monoid/08A.dhall +1/−1
- dhall-lang/tests/typecheck/success/prelude/Monoid/09A.dhall +1/−1
- dhall-lang/tests/typecheck/success/prelude/Monoid/10A.dhall +1/−1
- dhall.cabal +13/−3
- src/Dhall.hs +58/−35
- src/Dhall/Binary.hs +861/−836
- src/Dhall/Binary.hs-boot +10/−0
- src/Dhall/Core.hs +122/−382
- src/Dhall/Core.hs-boot +4/−0
- src/Dhall/Diff.hs +23/−8
- src/Dhall/Eval.hs +932/−0
- src/Dhall/Eval.hs-boot +8/−0
- src/Dhall/Format.hs +4/−8
- src/Dhall/Import.hs +18/−42
- src/Dhall/Import/HTTP.hs +151/−14
- src/Dhall/Import/Types.hs +4/−4
- src/Dhall/Main.hs +40/−24
- src/Dhall/Parser.hs +1/−1
- src/Dhall/Parser/Expression.hs +8/−10
- src/Dhall/Parser/Token.hs +28/−14
- src/Dhall/Pretty/Internal.hs +26/−13
- src/Dhall/Repl.hs +17/−12
- src/Dhall/Tutorial.hs +48/−50
- src/Dhall/TypeCheck.hs +107/−119
- src/Dhall/Util.hs +6/−0
- tests/Dhall/Test/Format.hs +48/−97
- tests/Dhall/Test/Import.hs +57/−78
- tests/Dhall/Test/Lint.hs +37/−41
- tests/Dhall/Test/Main.hs +35/−17
- tests/Dhall/Test/Normalization.hs +180/−276
- tests/Dhall/Test/Parser.hs +70/−181
- tests/Dhall/Test/QuickCheck.hs +21/−38
- tests/Dhall/Test/Regression.hs +6/−6
- tests/Dhall/Test/TypeCheck.hs +59/−106
- tests/Dhall/Test/Util.hs +46/−9
- tests/tutorial/unions3A.dhall +3/−2
- tests/tutorial/unions3B.dhall +5/−3
@@ -1,3 +1,32 @@+1.22.0++* Supports version 7.0.0 of the standard+ * See: https://github.com/dhall-lang/dhall-lang/releases/tag/v7.0.0+* BREAKING CHANGE: Remove deprecated `Path` type synonym+ * See: https://github.com/dhall-lang/dhall-haskell/pull/858+* BUG FIX: Correctly parse identifiers beginning with `http`+ * i.e. `httpPort` was supposed to be a valid identifier name and now is+ * See: https://github.com/dhall-lang/dhall-haskell/pull/870+* BUG FIX: Fix `dhall encode` bug+ * `dhall encode` bug was generating binary expressions that were valid+ (i.e. they would decode correctly) but were non-standard (i.e. hashing+ them would not match the hash you would normally get from a semantic+ integrity check)+ * Semantic integrity checks were not affected by this bug since they used+ a slightly different code path that generated the correct binary input to+ the hash. Only the `dhall decode` subcommand was affected+ * See: https://github.com/dhall-lang/dhall-haskell/pull/859+* BUG FIX: Fix for `Dhall.UnionType`+ * This fixes some expressions that would previously fail to marshal into+ Haskell, specifically those were the marshalling logic was built using+ the `UnionType` utilities+ * See: https://github.com/dhall-lang/dhall-haskell/pull/857+* Feature: New `--alpha` flag to α-normalize command-line output+ * See: https://github.com/dhall-lang/dhall-haskell/pull/855+* Performance improvements+ * The normalizer is now *much* faster+ * See: https://github.com/dhall-lang/dhall-haskell/pull/876+ 1.21.0 * Supports version 6.0.0 of the language standard
@@ -8,7 +8,7 @@ options :: Main.Options options = Main.Options- { Main.mode = Main.Default False+ { Main.mode = Main.Default False False , Main.explain = False , Main.plain = False , Main.ascii = False
@@ -0,0 +1,22 @@++let Nat = ∀(N : Type) → (N → N) → N → N+let n2 = λ(N : Type) → λ(s : N → N) → λ(z : N) → s (s z)+let n5 = λ(N : Type) → λ(s : N → N) → λ(z : N) → s (s (s (s (s z))))++let mul =+ λ(a : Nat) → λ(b : Nat) → λ(N : Type) → λ(s : N → N) → λ(z : N) → a N (b N s) z++let add =+ λ(a : Nat) → λ(b : Nat) → λ(N : Type) → λ(s : N → N) → λ(z : N) → a N s (b N s z)++let n10 = mul n2 n5+let n100 = mul n10 n10+let n1k = mul n10 n100+let n10k = mul n100 n100+let n100k = mul n10 n10k+let n1M = mul n10k n100+let n5M = mul n1M n5+let n10M = mul n1M n10+let n20M = mul n10M n2++in n1M Natural (λ (x:Natural) → x + 1) 0
@@ -0,0 +1,18 @@++let compose+ : ∀(a : Type) → ∀(b : Type) → ∀(c : Type) → (a → b) → (b → c) → a → c+ = λ(A : Type)+ → λ(B : Type)+ → λ(C : Type)+ → λ(f : A → B)+ → λ(g : B → C)+ → λ(x : A)+ → g (f x)++let composeN : ∀ (a : Type) → Natural → (a → a) → a → a+ = λ (a : Type)+ → λ (n : Natural)+ → λ (f : a → a)+ → Natural/fold n (a → a) (compose a a a f) (λ (x : a) → x)++in composeN Natural 100000 (λ (x : Natural) → x + 1) 0
@@ -0,0 +1,75 @@++let iterate+ = λ(n : Natural)+ → λ(a : Type)+ → λ(f : a → a)+ → λ(x : a)+ → List/build+ a+ ( λ(list : Type)+ → λ(cons : a → list → list)+ → List/fold+ { index : Natural, value : {} }+ ( List/indexed+ {}+ ( List/build+ {}+ ( λ(list : Type)+ → λ(cons : {} → list → list)+ → Natural/fold n list (cons {=})+ )+ )+ )+ list+ ( λ(y : { index : Natural, value : {} })+ → cons (Natural/fold y.index a f x)+ )+ )++let countTo =+ λ (x : Natural)+ → iterate x Natural (λ (x : Natural) → x + 1) 0++let sum =+ λ (xs : List Natural)+ → List/fold Natural xs Natural (λ (x : Natural) → λ (acc : Natural) → x + acc) 0+++let map+ : ∀(a : Type) → ∀(b : Type) → (a → b) → List a → List b+ = λ(a : Type)+ → λ(b : Type)+ → λ(f : a → b)+ → λ(xs : List a)+ → List/build+ b+ ( λ(list : Type)+ → λ(cons : b → list → list)+ → List/fold a xs list (λ(x : a) → cons (f x))+ )++let any+ : ∀(a : Type) → (a → Bool) → List a → Bool+ = λ(a : Type)+ → λ(f : a → Bool)+ → λ(xs : List a)+ → List/fold a xs Bool (λ(x : a) → λ(r : Bool) → f x || r) False++let filter+ : ∀(a : Type) → (a → Bool) → List a → List a+ = λ(a : Type)+ → λ(f : a → Bool)+ → λ(xs : List a)+ → List/build+ a+ ( λ(list : Type)+ → λ(cons : a → list → list)+ → List/fold+ a+ xs+ list+ (λ(x : a) → λ(xs : list) → if f x then cons x xs else xs)+ )++in sum (filter Natural Natural/even+ (map Natural Natural (λ(x:Natural) → x + 10) (countTo 1000)))
@@ -0,0 +1,45 @@++let iterate =+ λ(n : Natural)+ → λ(a : Type)+ → λ(f : a → a)+ → λ(x : a)+ → (Natural/fold n+ (a → List a → {fst:a, snd:List a})+ (λ (hyp : a → List a → {fst:a, snd:List a}) →+ λ (x : a) → λ (xs : List a)+ → let tup = hyp x xs+ in {fst = f (tup.fst), snd = tup.snd # [tup.fst]})+ (λ (x : a) → λ (xs : List a) → {fst=x, snd=xs})+ x ([] : List a)).snd++let countTo =+ λ (x : Natural)+ → iterate x Natural (λ (x : Natural) → x + 1) 0++let sum =+ λ (xs : List Natural)+ → List/fold Natural xs Natural (λ (x : Natural) → λ (acc : Natural) → x + acc) 0++let map+ = λ(a : Type)+ → λ(b : Type)+ → λ(f : a → b)+ → λ(xs : List a)+ → List/fold a xs (List b) (λ (x : a) → λ (xs : List b) → [f x] # xs) ([] : List b)++let any+ = λ(a : Type)+ → λ(f : a → Bool)+ → λ(xs : List a)+ → List/fold a xs Bool (λ(x : a) → λ(r : Bool) → f x || r) False++let filter+ = λ(a : Type)+ → λ(f : a → Bool)+ → λ(xs : List a)+ → List/fold a xs (List a)+ (λ (x : a) → λ (xs : List a) → if f x then [x] # xs else xs) ([] : List a)++in sum (filter Natural Natural/even+ (map Natural Natural (λ(x:Natural) → x + 10) (countTo 1000)))
@@ -72,7 +72,7 @@ term <- case Codec.Serialise.deserialiseOrFail bytes of Left _ -> Nothing Right term -> return term- case Dhall.Binary.decode term of+ case Dhall.Binary.decodeExpression term of Left _ -> Nothing Right expression -> return expression
@@ -1,17 +1,25 @@ { and =- ./and+ ./and sha256:0b2114fa33cd76652e4360f012bc082718944fe4c5b28c975483178f8d9b0a6d+ ? ./and , build =- ./build+ ./build sha256:add7cb9acacac705410088d876a7e4488e046a7aded304f06c51accffd7f1b7b+ ? ./build , even =- ./even+ ./even sha256:72a05ee550636a3acb768360fa51ba0db0326763e0cf1ceb737f0f3607fc0fe5+ ? ./even , fold =- ./fold+ ./fold sha256:39f60baf3950268c2e849e91dc6279ee41cd6b81892d54020d4fcd2ce30a96ae+ ? ./fold , not =- ./not+ ./not sha256:723df402df24377d8a853afed08d9d69a0a6d86e2e5b2bac8960b0d4756c7dc4+ ? ./not , odd =- ./odd+ ./odd sha256:6360fca3a745de32bd186cc7b71487a6398cd47d5119064eae491872c41d1999+ ? ./odd , or =- ./or+ ./or sha256:5c50738e84e1c4fed8343ebd57608500e1b61ac1f502aa52d6d6edb5c20b99e4+ ? ./or , show =- ./show+ ./show sha256:f85f6d2d921c37a2122cb2e2f8a0170e305b699debd0e6df5ef3370d806b5f61+ ? ./show }
@@ -1,1 +1,4 @@-{ show = ./show }+{ show =+ ./show sha256:ae645813cc4d8505a265df4d7564c95482f62bb3e07fc81681959599b6cee04f+ ? ./show+}
@@ -1,1 +1,4 @@-{ compose = ./compose }+{ compose =+ ./compose sha256:65ad8bbea530b3d8968785a7cf4a9a7976b67059aa15e3b61fcba600a40ae013+ ? ./compose+}
@@ -1,1 +1,7 @@-{ show = ./show, toDouble = ./toDouble }+{ show =+ ./show sha256:ecf8b0594cd5181bc45d3b7ea0d44d3ba9ad5dac6ec17bb8968beb65f4b1baa9+ ? ./show+, toDouble =+ ./toDouble sha256:77bc5d635dc4d952f37cc96f2a681d5ac503b4e8b21fc00055b1946adb5beda7+ ? ./toDouble+}
@@ -1,1 +1,7 @@-{ keyText = ./keyText, keyValue = ./keyValue }+{ keyText =+ ./keyText sha256:f7b6c802ca5764d03d5e9a6e48d9cb167c01392f775d9c2c87b83cdaa60ea0cc+ ? ./keyText+, keyValue =+ ./keyValue sha256:a0a97199d280c4cce72ffcbbf93b7ceda0a569cf4d173ac98e0aaaa78034b98c+ ? ./keyValue+}
@@ -1,39 +1,58 @@ { all =- ./all+ ./all sha256:7ac5bb6f77e9ffe9e2356d90968d39764a9a32f75980206e6b12f815bb83dd15+ ? ./all , any =- ./any+ ./any sha256:b8e9e13b25e799f342a81f6eda4075906eb1a19dfdcb10a0ca25925eba4033b8+ ? ./any , build =- ./build+ ./build sha256:8cf73fc1e115cfcb79bb9cd490bfcbd45c824e93c57a0e64c86c0c72e9ebbe42+ ? ./build , concat =- ./concat+ ./concat sha256:54e43278be13276e03bd1afa89e562e94a0a006377ebea7db14c7562b0de292b+ ? ./concat , concatMap =- ./concatMap+ ./concatMap sha256:3b2167061d11fda1e4f6de0522cbe83e0d5ac4ef5ddf6bb0b2064470c5d3fb64+ ? ./concatMap , filter =- ./filter+ ./filter sha256:8ebfede5bbfe09675f246c33eb83964880ac615c4b1be8d856076fdbc4b26ba6+ ? ./filter , fold =- ./fold+ ./fold sha256:10bb945c25ab3943bd9df5a32e633cbfae112b7d3af38591784687e436a8d814+ ? ./fold , generate =- ./generate+ ./generate sha256:78ff1ad96c08b88a8263eea7bc8381c078225cfcb759c496f792edb5a5e0b1a4+ ? ./generate , head =- ./head+ ./head sha256:0d2e65ba0aea908377e46d22020dc3ad970284f4ee4eb8e6b8c51e53038c0026+ ? ./head , indexed =- ./indexed+ ./indexed sha256:58bb44457fa81adf26f5123c1b2e8bef0c5aa22dac5fa5ebdfb7da84563b027f+ ? ./indexed , iterate =- ./iterate+ ./iterate sha256:e4999ccce190a2e2a6ab9cb188e3af6c40df474087827153005293f11bfe1d26+ ? ./iterate , last =- ./last+ ./last sha256:741226b741af152a1638491cdff7f3aa74baf080ada2e63429483f3d195a984d+ ? ./last , length =- ./length+ ./length sha256:42c6812c7a9e3c6e6fad88f77c5b3849503964e071cb784e22c38c888a401461+ ? ./length , map =- ./map+ ./map sha256:dd845ffb4568d40327f2a817eb42d1c6138b929ca758d50bc33112ef3c885680+ ? ./map , null =- ./null+ ./null sha256:2338e39637e9a50d66ae1482c0ed559bbcc11e9442bfca8f8c176bbcd9c4fc80+ ? ./null , replicate =- ./replicate+ ./replicate sha256:d4250b45278f2d692302489ac3e78280acb238d27541c837ce46911ff3baa347+ ? ./replicate , reverse =- ./reverse+ ./reverse sha256:ad99d224d61852de6696da5a7d04c98dbe676fe67d5e4ef4f19e9aaa27006e9d+ ? ./reverse , shifted =- ./shifted+ ./shifted sha256:54fb22c7e952ebce1cfc0fcdd33ce4cfa817bff9d6564af268dea6685f8b5dfe+ ? ./shifted , unzip =- ./unzip+ ./unzip sha256:4d6003e9e683a289fe33f4c90f958eb1e08ea0bbb474210fcd90d1885c9660e9+ ? ./unzip }
@@ -1,23 +1,34 @@ { build =- ./build+ ./build sha256:e7e25e6c4f1d8e573606ed1bef725396ac2de5c68f7c5d329ffc5822085b984c+ ? ./build , enumerate =- ./enumerate+ ./enumerate sha256:0cf083980a752b21ce0df9fc2222a4c139f50909e2353576e26a191002aa1ce3+ ? ./enumerate , even =- ./even+ ./even sha256:b85b8b56892dfef881e1c0e79eade0b949528f792aac0ea42432b315ede4ee66+ ? ./even , fold =- ./fold+ ./fold sha256:fd01c931e585a8f5fd049af7b076b862ea164f1813b34800c7616a49e549ee06+ ? ./fold , isZero =- ./isZero+ ./isZero sha256:1be98236800ed2d5cff44f16ca02b34b0c37dfa239d9e0d63d9d2c6eeae3d1d1+ ? ./isZero , odd =- ./odd+ ./odd sha256:ab3c729262c642ec1cdb72a81e910fcfaf2aea13e3961d0bf1bec83efea5aac5+ ? ./odd , product =- ./product+ ./product sha256:e3e6fd76207875b81d39f79fdbc90b5e640444c04fb3d84c2c9326748f0b26e6+ ? ./product , sum =- ./sum+ ./sum sha256:33f7f4c3aff62e5ecf4848f964363133452d420dcde045784518fb59fa970037+ ? ./sum , show =- ./show+ ./show sha256:684ed560ad86f438efdea229eca122c29e8e14f397ed32ec97148d578ca5aa21+ ? ./show , toDouble =- ./toDouble+ ./toDouble sha256:d5eb52143dcd35b46a6f0cdb2d3cbf31a14b6daeba56e29066f8e344c9fb6e81+ ? ./toDouble , toInteger =- ./toInteger+ ./toInteger sha256:160d2d278619f3da34a1f4f02e739a447e4f2aa5a2978c45b710515b41491e1f+ ? ./toInteger }
@@ -1,27 +1,40 @@ { all =- ./all+ ./all sha256:b9b015fe8be14da940901aa1510ee1d5e205df37ee651c32ac975a799782c410+ ? ./all , any =- ./any+ ./any sha256:0a637c0f2cc7d30b8f0bca021d2ee1ad1213fb9d9712c669b29feab66a590eaf+ ? ./any , build =- ./build+ ./build sha256:f331299d1279cfb88dd25a5acfdd64130900991b6154239ad343a2883f6eb50c+ ? ./build , concat =- ./concat+ ./concat sha256:b49a3b7dc49eb83d150977caa5ae347be1cbbe14e3b6d0e07349bd2e5f707d69+ ? ./concat , filter =- ./filter+ ./filter sha256:b3d5e19a6cec592a76c12167a9e5e1e76649e776229d70a11c77b76cd29f617e+ ? ./filter , fold =- ./fold+ ./fold sha256:62139ff410ca84302acebe763a8a1794420dd472d907384c7fb80df2a2180302+ ? ./fold , head =- ./head+ ./head sha256:b0b5d257294515f1de35f24fa83e54d7f1d5ebca9c3c1fc903a80ab40e19b3a6+ ? ./head , last =- ./last+ ./last sha256:f839221a8a04adae6c501458eb264e7f4e375a1facb294cb80caacfd012a6765+ ? ./last , length =- ./length+ ./length sha256:722a3754a411c053f006a32c506a6d1b14869c2ab799169df9cdac346edf07d3+ ? ./length , map =- ./map+ ./map sha256:e7f44219250b89b094fbf9996e04b5daafc0902d864113420072ae60706ac73d+ ? ./map , null =- ./null+ ./null sha256:efc43103e49b56c5bf089db8e0365bbfc455b8a2f0dc6ee5727a3586f85969fd+ ? ./null , toList =- ./toList+ ./toList sha256:390fe99619e9a25e71a253a2b33011f9e5fa26a7d990795205543d1edd72ce5b+ ? ./toList , unzip =- ./unzip+ ./unzip sha256:7b517bc2a8a4dbec044c6bea5e059cafde5a0cb1d3a5e7d13d346c9327a00f30+ ? ./unzip }
@@ -10,38 +10,32 @@ ./concatMapSep ", " Natural Natural/show ([] : List Natural) = "" ``` -}- let concatMapSep- : ∀(separator : Text) → ∀(a : Type) → (a → Text) → List a → Text- = λ(separator : Text)- → λ(a : Type)- → λ(f : a → Text)- → λ(elements : List a)- → let status =- List/fold- a- elements- < Empty : {} | NonEmpty : Text >- ( λ(element : a)- → λ(status : < Empty : {} | NonEmpty : Text >)- → merge- { Empty =- λ(_ : {}) → < NonEmpty = f element | Empty : {} >- , NonEmpty =- λ(result : Text)- → < NonEmpty =- f element ++ separator ++ result- | Empty :- {}- >- }- status- : < Empty : {} | NonEmpty : Text >- )- < Empty = {=} | NonEmpty : Text >- - in merge- { Empty = λ(_ : {}) → "", NonEmpty = λ(result : Text) → result }- status- : Text+let Status = < Empty | NonEmpty : Text >++let concatMapSep+ : ∀(separator : Text) → ∀(a : Type) → (a → Text) → List a → Text+ = λ(separator : Text)+ → λ(a : Type)+ → λ(f : a → Text)+ → λ(elements : List a)+ → let status =+ List/fold+ a+ elements+ Status+ ( λ(x : a)+ → λ(status : Status)+ → merge+ { Empty =+ Status.NonEmpty (f x)+ , NonEmpty =+ λ(result : Text)+ → Status.NonEmpty (f x ++ separator ++ result)+ }+ status+ )+ Status.Empty+ + in merge { Empty = "", NonEmpty = λ(result : Text) → result } status in concatMapSep
@@ -9,36 +9,30 @@ ./concatSep ", " ([] : List Text) = "" ``` -}- let concatSep- : ∀(separator : Text) → ∀(elements : List Text) → Text- = λ(separator : Text)- → λ(elements : List Text)- → let status =- List/fold- Text- elements- < Empty : {} | NonEmpty : Text >- ( λ(element : Text)- → λ(status : < Empty : {} | NonEmpty : Text >)- → merge- { Empty =- λ(_ : {}) → < NonEmpty = element | Empty : {} >- , NonEmpty =- λ(result : Text)- → < NonEmpty =- element ++ separator ++ result- | Empty :- {}- >- }- status- : < Empty : {} | NonEmpty : Text >- )- < Empty = {=} | NonEmpty : Text >- - in merge- { Empty = λ(_ : {}) → "", NonEmpty = λ(result : Text) → result }- status- : Text+let Status = < Empty | NonEmpty : Text >++let concatSep+ : ∀(separator : Text) → ∀(elements : List Text) → Text+ = λ(separator : Text)+ → λ(elements : List Text)+ → let status =+ List/fold+ Text+ elements+ Status+ ( λ(element : Text)+ → λ(status : Status)+ → merge+ { Empty =+ Status.NonEmpty element+ , NonEmpty =+ λ(result : Text)+ → Status.NonEmpty (element ++ separator ++ result)+ }+ status+ )+ Status.Empty+ + in merge { Empty = "", NonEmpty = λ(result : Text) → result } status in concatSep
@@ -1,11 +1,16 @@ { concat =- ./concat+ ./concat sha256:35e20d9403fbadb1a0061edb84e076ed56313709fa4bc8124d86ff54896f20ac+ ? ./concat , concatMap =- ./concatMap+ ./concatMap sha256:175d893ad7f2b2c05fff9e32f0d9cbadc7f5fce57945071508cf3603f8aa298e+ ? ./concatMap , concatMapSep =- ./concatMapSep+ ./concatMapSep sha256:46b81a9e211fb8278bf2793e75e8175fef79e0e3e478ef1016e3233ecc2ddfe6+ ? ./concatMapSep , concatSep =- ./concatSep+ ./concatSep sha256:d28e61f5057a240e857e09dba1b040fa3477bddb9659c5606c760852a9165890+ ? ./concatSep , show =- ./show+ ./show sha256:c9dc5de3e5f32872dbda57166804865e5e80785abe358ff61f1d8ac45f1f4784+ ? ./show }
@@ -1,19 +1,28 @@ { `Bool` =- ./Bool/package.dhall+ ./Bool/package.dhall sha256:7ee950e7c2142be5923f76d00263e536b71d96cb9c190d7743c1679501ddeb0a+ ? ./Bool/package.dhall , `Double` =- ./Double/package.dhall+ ./Double/package.dhall sha256:b8d20ab3216083622ae371fb42a6732bc67bb2d66e84989c8ddba7556a336cf7+ ? ./Double/package.dhall , Function =- ./Function/package.dhall+ ./Function/package.dhall sha256:74c3822b98b9d37f9f820af8e1a7ee790bcfac03050eabd45af4a255fb93e026+ ? ./Function/package.dhall , `Integer` =- ./Integer/package.dhall+ ./Integer/package.dhall sha256:eb464566d3192dd16ce915a9bd874aaaad612d5c69beb356e5b7d2e0c4949dcf+ ? ./Integer/package.dhall , `List` =- ./List/package.dhall+ ./List/package.dhall sha256:108be3af5ebd465f7091039f2216c433e65ae5d25556a9a71786dd84d33ef49a+ ? ./List/package.dhall , `Natural` =- ./Natural/package.dhall+ ./Natural/package.dhall sha256:fe08155c3a04500df847ca94d013ecd3dfc73ab5c136109b2414fce3ec42b63a+ ? ./Natural/package.dhall , `Optional` =- ./Optional/package.dhall+ ./Optional/package.dhall sha256:36a366af67a3c26cd5d196e095d3023f18953c5b5db3a03956fa554609e5442a+ ? ./Optional/package.dhall , JSON =- ./JSON/package.dhall+ ./JSON/package.dhall sha256:7f0c25a292e5d34ddfbbf3f6d90505567382f95d822b04f5810745f81ab1ef35+ ? ./JSON/package.dhall , `Text` =- ./Text/package.dhall+ ./Text/package.dhall sha256:c8bc93456397476051dc674c180ddd5db098546861c8df24bda8284511d3305e+ ? ./Text/package.dhall }
@@ -0,0 +1,1 @@+../failure/cycle.dhall
@@ -0,0 +1,1 @@+Hello, world!
@@ -0,0 +1,20 @@+{- This is a "referentially opaque" import (i.e. an import that is not+ globally addressable), which cannot be imported by a "referentially+ transparent" import (i.e. an import that is globally addressable).++ This test file is used in a failing test to verify that referentially+ transparent imports cannot import referentially opaque imports. In the test+ suite this file is actually imported via its GitHub URL (not its local file+ path), so it plays the role of the referentially transparent import. Then,+ this file attempts to import a referentially opaque import (an environment+ variable in this case) to verify that the import fails.++ For this test file we need to select a referentially opaque import that would+ likely succeed if imported on its own, so that a non-compliant implementation+ doesn't fail this test for the wrong reason (i.e. due to the referentially+ opaque not being present). In general, we can't guarantee that referentially+ opaque imports exist (because they are referentially opaque!), but the+ `HOME` environment variable has a high likelihood of bring present on a POSIX+ system.+-}+env:HOME as Text
@@ -0,0 +1,1 @@+(./alternativeHashMismatchB.dhall sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) ? 42
@@ -0,0 +1,1 @@+42
@@ -0,0 +1,1 @@+(../data/example.txt) ? 42
@@ -0,0 +1,1 @@+42
@@ -1,1 +1,1 @@-λ(Foo : Text) → < Foo = Foo | Bar : Natural >+< Bar : Natural | Foo : Text >.Foo
@@ -1,9 +0,0 @@--- Verify that an implementation is processing escape sequences correctly--''-''${-'''-$-"-\-''
@@ -1,1 +0,0 @@-"\${\n''\n\$\n\"\n\\\n"
@@ -1,15 +0,0 @@-{- The indent is computed as the minimum number of leading spaces over all lines- in a multi-line literal, including the line right before the closing quotes.- In this case, there are three lines:-- * The first line containing " foo" with two leading spaces- * The second line containing " bar" with two leading spaces- * The third line containing " " with two leading spaces-- Therefore we strip two leading spaces from all three lines--}--''- foo- bar- ''
@@ -1,1 +0,0 @@-"foo\nbar\n"
@@ -1,7 +0,0 @@--- Non-trivial example that combines several multi-line literal features--λ(x : Text) → ''- ${x} baz- bar- foo- ''
@@ -1,1 +0,0 @@-λ(x : Text) → "${x} baz\n bar\n foo\n "
@@ -1,16 +0,0 @@-{- The indent is computed as the minimum number of leading spaces over all lines- in a multi-line literal, including the line right before the closing quotes.- In this case, there are three lines:-- * The first line containing " foo" with two leading spaces- * The second line containing " bar" with two leading spaces- * The third line containing "" with zero leading spaces-- Since the last line has zero leading spaces, the minimum number of leading- spaces over all three lines is zero, so we don't strip any spaces.--}--''- foo- bar-''
@@ -1,1 +0,0 @@-" foo\n bar\n"
@@ -1,9 +0,0 @@-{- This example verifies that an implementation is correctly breaking leading- spaces at interpolated expressions. The first line has the fewest number of- leading spaces (2) due to the interruption by the interpolated expression.--}--''-${Natural/show 1} foo- bar-''
@@ -1,1 +0,0 @@-"${Natural/show 1} foo\n bar\n"
@@ -1,8 +0,0 @@-{- A comment within the interior of a multi-line literal counts as part of the- literal--}--''--- Hello-{- world -}-''
@@ -1,1 +0,0 @@-"-- Hello\n{- world -}\n"
@@ -1,6 +0,0 @@-{- This is how you encode a multi-line literal that contains no newlines-- The leading newline is stripped--}-''-foo''
@@ -1,1 +0,0 @@-"foo"
@@ -1,7 +0,0 @@-{- Verify that an implementation is correctly preserving newlines in the- corresponding double-quoted literal--}--''-foo-bar''
@@ -1,1 +0,0 @@-"foo\nbar"
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.and [ True, False, True ]+../../../../../../Prelude/Bool/and [ True, False, True ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.and ([] : List Bool)+../../../../../../Prelude/Bool/and ([] : List Bool)
@@ -1,2 +1,2 @@-(../../../../../../Prelude/package.dhall).`Bool`.build +../../../../../../Prelude/Bool/build (λ(bool : Type) → λ(true : bool) → λ(false : bool) → true)
@@ -1,2 +1,2 @@-(../../../../../../Prelude/package.dhall).`Bool`.build +../../../../../../Prelude/Bool/build (λ(bool : Type) → λ(true : bool) → λ(false : bool) → false)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.even [ False, True, False ]+../../../../../../Prelude/Bool/even [ False, True, False ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.even [ False, True ]+../../../../../../Prelude/Bool/even [ False, True ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.even [ False ]+../../../../../../Prelude/Bool/even [ False ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.even ([] : List Bool)+../../../../../../Prelude/Bool/even ([] : List Bool)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.fold True Natural 0 1+../../../../../../Prelude/Bool/fold True Natural 0 1
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.fold False Natural 0 1+../../../../../../Prelude/Bool/fold False Natural 0 1
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.not True+../../../../../../Prelude/Bool/not True
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.not False+../../../../../../Prelude/Bool/not False
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.odd [ True, False, True ]+../../../../../../Prelude/Bool/odd [ True, False, True ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.odd [ True, False ]+../../../../../../Prelude/Bool/odd [ True, False ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.odd [ True ]+../../../../../../Prelude/Bool/odd [ True ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.odd ([] : List Bool)+../../../../../../Prelude/Bool/odd ([] : List Bool)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.or [ True, False, True ]+../../../../../../Prelude/Bool/or [ True, False, True ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.or ([] : List Bool)+../../../../../../Prelude/Bool/or ([] : List Bool)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.show True+../../../../../../Prelude/Bool/show True
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Bool`.show False+../../../../../../Prelude/Bool/show False
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Double`.show -3.1+../../../../../../Prelude/Double/show -3.1
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Double`.show 0.4+../../../../../../Prelude/Double/show 0.4
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Integer`.show -3+../../../../../../Prelude/Integer/show -3
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Integer`.show +0+../../../../../../Prelude/Integer/show +0
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Integer`.toDouble -3+../../../../../../Prelude/Integer/toDouble -3
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Integer`.toDouble +2+../../../../../../Prelude/Integer/toDouble +2
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.all Natural Natural/even [ 2, 3, 5 ]+../../../../../../Prelude/List/all Natural Natural/even [ 2, 3, 5 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.all Natural Natural/even ([] : List Natural)+../../../../../../Prelude/List/all Natural Natural/even ([] : List Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.any Natural Natural/even [ 2, 3, 5 ]+../../../../../../Prelude/List/any Natural Natural/even [ 2, 3, 5 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.any Natural Natural/even ([] : List Natural)+../../../../../../Prelude/List/any Natural Natural/even ([] : List Natural)
@@ -1,4 +1,4 @@-(../../../../../../Prelude/package.dhall).`List`.build+../../../../../../Prelude/List/build Text ( λ(list : Type) → λ(cons : Text → list → list)
@@ -1,4 +1,4 @@-(../../../../../../Prelude/package.dhall).`List`.build+../../../../../../Prelude/List/build Text ( λ(list : Type) → λ(cons : Text → list → list)
@@ -1,4 +1,4 @@-(../../../../../../Prelude/package.dhall).`List`.concat Natural+../../../../../../Prelude/List/concat Natural [ [ 0, 1, 2 ] , [ 3, 4 ] , [ 5, 6, 7, 8 ]
@@ -1,4 +1,4 @@-(../../../../../../Prelude/package.dhall).`List`.concat Natural+../../../../../../Prelude/List/concat Natural [ [] : List Natural , [] : List Natural , [] : List Natural
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.concatMap Natural Natural (λ(n : Natural) → [ n, n ]) [ 2, 3, 5 ]+../../../../../../Prelude/List/concatMap Natural Natural (λ(n : Natural) → [ n, n ]) [ 2, 3, 5 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.concatMap Natural Natural (λ(n : Natural) → [ n, n ]) ([] : List Natural)+../../../../../../Prelude/List/concatMap Natural Natural (λ(n : Natural) → [ n, n ]) ([] : List Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.filter Natural Natural/even [ 2, 3, 5 ]+../../../../../../Prelude/List/filter Natural Natural/even [ 2, 3, 5 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.filter Natural Natural/odd [ 2, 3, 5 ]+../../../../../../Prelude/List/filter Natural Natural/odd [ 2, 3, 5 ]
@@ -1,4 +1,4 @@-(../../../../../../Prelude/package.dhall).`List`.fold+../../../../../../Prelude/List/fold Natural [ 2, 3, 5 ] Natural
@@ -1,5 +1,5 @@ λ(nil : Natural)-→ (../../../../../../Prelude/package.dhall).`List`.fold+→ ../../../../../../Prelude/List/fold Natural [ 2, 3, 5 ] Natural
@@ -1,4 +1,4 @@ λ(list : Type) → λ(cons : Natural → list → list) → λ(nil : list)-→ (../../../../../../Prelude/package.dhall).`List`.fold Natural [ 2, 3, 5 ] list cons nil+→ ../../../../../../Prelude/List/fold Natural [ 2, 3, 5 ] list cons nil
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.generate 5 Bool Natural/even+../../../../../../Prelude/List/generate 5 Bool Natural/even
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.generate 0 Bool Natural/even+../../../../../../Prelude/List/generate 0 Bool Natural/even
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.head Natural [ 0, 1, 2 ]+../../../../../../Prelude/List/head Natural [ 0, 1, 2 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.head Natural ([] : List Natural)+../../../../../../Prelude/List/head Natural ([] : List Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.indexed Bool [ True, False, True ]+../../../../../../Prelude/List/indexed Bool [ True, False, True ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.indexed Bool ([] : List Bool)+../../../../../../Prelude/List/indexed Bool ([] : List Bool)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.iterate 10 Natural (λ(x : Natural) → x * 2) 1+../../../../../../Prelude/List/iterate 10 Natural (λ(x : Natural) → x * 2) 1
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.iterate 0 Natural (λ(x : Natural) → x * 2) 1+../../../../../../Prelude/List/iterate 0 Natural (λ(x : Natural) → x * 2) 1
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.last Natural [ 0, 1, 2 ]+../../../../../../Prelude/List/last Natural [ 0, 1, 2 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.last Natural ([] : List Natural)+../../../../../../Prelude/List/last Natural ([] : List Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.length Natural [ 0, 1, 2 ]+../../../../../../Prelude/List/length Natural [ 0, 1, 2 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.length Natural ([] : List Natural)+../../../../../../Prelude/List/length Natural ([] : List Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.map Natural Bool Natural/even [ 2, 3, 5 ]+../../../../../../Prelude/List/map Natural Bool Natural/even [ 2, 3, 5 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.map Natural Bool Natural/even ([] : List Natural)+../../../../../../Prelude/List/map Natural Bool Natural/even ([] : List Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.null Natural [ 0, 1, 2 ]+../../../../../../Prelude/List/null Natural [ 0, 1, 2 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.null Natural ([] : List Natural)+../../../../../../Prelude/List/null Natural ([] : List Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.replicate 9 Natural 1+../../../../../../Prelude/List/replicate 9 Natural 1
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.replicate 0 Natural 1+../../../../../../Prelude/List/replicate 0 Natural 1
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.reverse Natural [ 0, 1, 2 ]+../../../../../../Prelude/List/reverse Natural [ 0, 1, 2 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.reverse Natural ([] : List Natural)+../../../../../../Prelude/List/reverse Natural ([] : List Natural)
@@ -1,4 +1,4 @@-(../../../../../../Prelude/package.dhall).`List`.shifted+../../../../../../Prelude/List/shifted Bool [ [ { index = 0, value = True } , { index = 1, value = True }
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.shifted Bool ([] : List (List { index : Natural, value : Bool }))+../../../../../../Prelude/List/shifted Bool ([] : List (List { index : Natural, value : Bool }))
@@ -1,4 +1,4 @@-(../../../../../../Prelude/package.dhall).`List`.unzip+../../../../../../Prelude/List/unzip Text Bool [ { _1 = "ABC", _2 = True }
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`List`.unzip Text Bool ([] : List { _1 : Text, _2 : Bool })+../../../../../../Prelude/List/unzip Text Bool ([] : List { _1 : Text, _2 : Bool })
@@ -1,4 +1,4 @@-(../../../../../../Prelude/package.dhall).`Natural`.build+../../../../../../Prelude/Natural/build ( λ(natural : Type) → λ(succ : natural → natural) → λ(zero : natural)
@@ -1,4 +1,4 @@-(../../../../../../Prelude/package.dhall).`Natural`.build+../../../../../../Prelude/Natural/build ( λ(natural : Type) → λ(succ : natural → natural) → λ(zero : natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.enumerate 10+../../../../../../Prelude/Natural/enumerate 10
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.enumerate 0+../../../../../../Prelude/Natural/enumerate 0
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.even 3+../../../../../../Prelude/Natural/even 3
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.even 0+../../../../../../Prelude/Natural/even 0
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.fold 3 Natural (λ(x : Natural) → 5 * x) 1+../../../../../../Prelude/Natural/fold 3 Natural (λ(x : Natural) → 5 * x) 1
@@ -1,1 +1,1 @@-λ(zero : Natural) → (../../../../../../Prelude/package.dhall).`Natural`.fold 3 Natural (λ(x : Natural) → 5 * x) zero+λ(zero : Natural) → ../../../../../../Prelude/Natural/fold 3 Natural (λ(x : Natural) → 5 * x) zero
@@ -1,4 +1,4 @@ λ(natural : Type) → λ(succ : natural → natural) → λ(zero : natural)-→ (../../../../../../Prelude/package.dhall).`Natural`.fold 3 natural succ zero+→ ../../../../../../Prelude/Natural/fold 3 natural succ zero
@@ -1,1 +1,4 @@-λ(natural : Type) → λ(succ : natural → natural) → λ(zero : natural) → succ (succ (succ zero))+ λ(natural : Type)+→ λ(succ : natural → natural)+→ λ(zero : natural)+→ succ (succ (succ zero))
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.isZero 2+../../../../../../Prelude/Natural/isZero 2
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.isZero 0+../../../../../../Prelude/Natural/isZero 0
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.odd 3+../../../../../../Prelude/Natural/odd 3
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.odd 0+../../../../../../Prelude/Natural/odd 0
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.product [ 2, 3, 5 ]+../../../../../../Prelude/Natural/product [ 2, 3, 5 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.product ([] : List Natural)+../../../../../../Prelude/Natural/product ([] : List Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.show 3+../../../../../../Prelude/Natural/show 3
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.show 0+../../../../../../Prelude/Natural/show 0
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.sum [ 2, 3, 5 ]+../../../../../../Prelude/Natural/sum [ 2, 3, 5 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.sum ([] : List Natural)+../../../../../../Prelude/Natural/sum ([] : List Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.toDouble 3+../../../../../../Prelude/Natural/toDouble 3
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.toDouble 0+../../../../../../Prelude/Natural/toDouble 0
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.toInteger 3+../../../../../../Prelude/Natural/toInteger 3
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Natural`.toInteger 0+../../../../../../Prelude/Natural/toInteger 0
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.all Natural Natural/even (Some 3)+../../../../../../Prelude/Optional/all Natural Natural/even (Some 3)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.all Natural Natural/even (None Natural)+../../../../../../Prelude/Optional/all Natural Natural/even (None Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.any Natural Natural/even (Some 2)+../../../../../../Prelude/Optional/any Natural Natural/even (Some 2)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.any Natural Natural/even (None Natural)+../../../../../../Prelude/Optional/any Natural Natural/even (None Natural)
@@ -1,4 +1,4 @@-(../../../../../../Prelude/package.dhall).`Optional`.build+../../../../../../Prelude/Optional/build Natural ( λ(optional : Type) → λ(some : Natural → optional)
@@ -1,4 +1,4 @@-(../../../../../../Prelude/package.dhall).`Optional`.build+../../../../../../Prelude/Optional/build Natural ( λ(optional : Type) → λ(some : Natural → optional)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.concat Natural (Some (Some 1))+../../../../../../Prelude/Optional/concat Natural (Some (Some 1))
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.concat Natural (Some (None Natural))+../../../../../../Prelude/Optional/concat Natural (Some (None Natural))
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.concat Natural (None (Optional Natural))+../../../../../../Prelude/Optional/concat Natural (None (Optional Natural))
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.filter Natural Natural/even (Some 2)+../../../../../../Prelude/Optional/filter Natural Natural/even (Some 2)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.filter Natural Natural/odd (Some 2)+../../../../../../Prelude/Optional/filter Natural Natural/odd (Some 2)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.fold Natural (Some 2) Natural (λ(x : Natural) → x) 0+../../../../../../Prelude/Optional/fold Natural (Some 2) Natural (λ(x : Natural) → x) 0
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.fold Natural (None Natural) Natural (λ(x : Natural) → x) 0+../../../../../../Prelude/Optional/fold Natural (None Natural) Natural (λ(x : Natural) → x) 0
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.head Natural [ None Natural, Some 1, Some 2 ]+../../../../../../Prelude/Optional/head Natural [ None Natural, Some 1, Some 2 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.head Natural [ None Natural, None Natural ]+../../../../../../Prelude/Optional/head Natural [ None Natural, None Natural ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.head Natural ([] : List (Optional Natural))+../../../../../../Prelude/Optional/head Natural ([] : List (Optional Natural))
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.last Natural [ None Natural, Some 1, Some 2 ]+../../../../../../Prelude/Optional/last Natural [ None Natural, Some 1, Some 2 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.last Natural [ None Natural, None Natural ]+../../../../../../Prelude/Optional/last Natural [ None Natural, None Natural ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.last Natural ([] : List (Optional Natural))+../../../../../../Prelude/Optional/last Natural ([] : List (Optional Natural))
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.length Natural (Some 2)+../../../../../../Prelude/Optional/length Natural (Some 2)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.length Natural (None Natural)+../../../../../../Prelude/Optional/length Natural (None Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.map Natural Bool Natural/even (Some 3)+../../../../../../Prelude/Optional/map Natural Bool Natural/even (Some 3)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.map Natural Bool Natural/even (None Natural)+../../../../../../Prelude/Optional/map Natural Bool Natural/even (None Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.null Natural (Some 2)+../../../../../../Prelude/Optional/null Natural (Some 2)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.null Natural (None Natural)+../../../../../../Prelude/Optional/null Natural (None Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.toList Natural (Some 1)+../../../../../../Prelude/Optional/toList Natural (Some 1)
@@ -1,1 +1,1 @@-[ 1 ] : List Natural+[ 1 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.toList Natural (None Natural)+../../../../../../Prelude/Optional/toList Natural (None Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.unzip Text Bool (Some { _1 = "ABC", _2 = True })+../../../../../../Prelude/Optional/unzip Text Bool (Some { _1 = "ABC", _2 = True })
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Optional`.unzip Text Bool (None { _1 : Text, _2 : Bool })+../../../../../../Prelude/Optional/unzip Text Bool (None { _1 : Text, _2 : Bool })
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Text`.concat [ "ABC", "DEF", "GHI" ]+../../../../../../Prelude/Text/concat [ "ABC", "DEF", "GHI" ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Text`.concat ([] : List Text)+../../../../../../Prelude/Text/concat ([] : List Text)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Text`.concatMap Natural (λ(n : Natural) → "${Natural/show n} ") [ 0, 1, 2 ]+../../../../../../Prelude/Text/concatMap Natural (λ(n : Natural) → "${Natural/show n} ") [ 0, 1, 2 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Text`.concatMap Natural (λ(n : Natural) → "${Natural/show n} ") ([] : List Natural)+../../../../../../Prelude/Text/concatMap Natural (λ(n : Natural) → "${Natural/show n} ") ([] : List Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Text`.concatMapSep ", " Natural Natural/show [ 0, 1, 2 ]+../../../../../../Prelude/Text/concatMapSep ", " Natural Natural/show [ 0, 1, 2 ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Text`.concatMapSep ", " Natural Natural/show ([] : List Natural)+../../../../../../Prelude/Text/concatMapSep ", " Natural Natural/show ([] : List Natural)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Text`.concatSep ", " [ "ABC", "DEF", "GHI" ]+../../../../../../Prelude/Text/concatSep ", " [ "ABC", "DEF", "GHI" ]
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Text`.concatSep ", " ([] : List Text)+../../../../../../Prelude/Text/concatSep ", " ([] : List Text)
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Text`.show "ABC"+../../../../../../Prelude/Text/show "ABC"
@@ -1,1 +1,1 @@-(../../../../../../Prelude/package.dhall).`Text`.show "\u0000 \$ \\ \n \u263a"+../../../../../../Prelude/Text/show "\u0000 \$ \\ \n \u263a"
@@ -1,6 +1,6 @@-let Text/concatMap = (../../../Prelude/package.dhall).`Text`.concatMap+let Text/concatMap = ../../../Prelude/Text/concatMap -let Text/concatSep = (../../../Prelude/package.dhall).`Text`.concatSep+let Text/concatSep = ../../../Prelude/Text/concatSep let Row = { cores :
@@ -1,4 +1,4 @@- λ ( _+ λ ( xs : List { cores : Natural@@ -36,9 +36,9 @@ , user : Optional Text }- _+ xs Text- ( λ ( _+ ( λ ( x : { cores : Natural , host :@@ -57,156 +57,113 @@ Optional Text } )- → λ(_ : Text)+ → λ(y : Text) → '' ${Optional/fold Text- _@1.user+ x.user Text- (λ(user : Text) → "${user}@${_@1.host}")- _@1.host} ${merge- { Empty = λ(_ : {}) → "", NonEmpty = λ(_ : Text) → _ }- ( List/fold- Text- _@1.platforms- < Empty : {} | NonEmpty : Text >- ( λ(_ : Text)- → λ(_ : < Empty : {} | NonEmpty : Text >)- → merge- { Empty =- λ(_ : {}) → < NonEmpty = _@2 | Empty : {} >- , NonEmpty =- λ(_ : Text)- → < NonEmpty = _@2 ++ "," ++ _ | Empty : {} >- }- _- : < Empty : {} | NonEmpty : Text >- )- < Empty = {=} | NonEmpty : Text >+ (λ(user : Text) → "${user}@${x.host}")+ x.host} ${merge+ { Empty = "", NonEmpty = λ(result : Text) → result }+ ( List/fold+ Text+ x.platforms+ < Empty | NonEmpty : Text >+ ( λ(element : Text)+ → λ(status : < Empty | NonEmpty : Text >)+ → merge+ { Empty =+ < Empty | NonEmpty : Text >.NonEmpty element+ , NonEmpty =+ λ(result : Text)+ → < Empty | NonEmpty : Text >.NonEmpty+ ("${element},${result}")+ }+ status )- : Text} ${_@1.key} ${Integer/show- ( Natural/toInteger _@1.cores- )} ${Integer/show- ( Natural/toInteger- _@1.speedFactor- )} ${merge- { Empty =- λ(_ : {}) → ""- , NonEmpty =- λ(_ : Text) → _- }- ( List/fold- Text- _@1.supportedFeatures- < Empty :- {}- | NonEmpty :- Text- >- ( λ(_ : Text)- → λ ( _- : < Empty :- {}- | NonEmpty :- Text- >- )- → merge- { Empty =- λ(_ : {})- → < NonEmpty =- _@2- | Empty :- {}- >- , NonEmpty =- λ(_ : Text)- → < NonEmpty =- _@2- ++ ","- ++ _- | Empty :- {}- >- }- _- : < Empty :- {}+ < Empty | NonEmpty : Text >.Empty+ )} ${x.key} ${Integer/show+ ( Natural/toInteger x.cores+ )} ${Integer/show+ ( Natural/toInteger x.speedFactor+ )} ${merge+ { Empty =+ ""+ , NonEmpty =+ λ(result : Text) → result+ }+ ( List/fold+ Text+ x.supportedFeatures+ < Empty | NonEmpty : Text >+ ( λ(element : Text)+ → λ ( status+ : < Empty+ | NonEmpty :+ Text+ >+ )+ → merge+ { Empty =+ < Empty+ | NonEmpty :+ Text+ >.NonEmpty+ element+ , NonEmpty =+ λ(result : Text)+ → < Empty+ | NonEmpty :+ Text+ >.NonEmpty+ "${element},${result}"+ }+ status+ )+ < Empty+ | NonEmpty :+ Text+ >.Empty+ )} ${merge+ { Empty =+ ""+ , NonEmpty =+ λ(result : Text) → result+ }+ ( List/fold+ Text+ x.mandatoryFeatures+ < Empty | NonEmpty : Text >+ ( λ(element : Text)+ → λ ( status+ : < Empty+ | NonEmpty :+ Text+ >+ )+ → merge+ { Empty =+ < Empty+ | NonEmpty :+ Text+ >.NonEmpty+ element+ , NonEmpty =+ λ(result : Text)+ → < Empty | NonEmpty : Text- >- )- < Empty =- {=}- | NonEmpty :- Text- >- )- : Text} ${merge- { Empty =- λ(_ : {})- → ""- , NonEmpty =- λ ( _- : Text- )- → _- }- ( List/fold- Text- _@1.mandatoryFeatures- < Empty :- {}- | NonEmpty :- Text- >- ( λ ( _- : Text- )- → λ ( _- : < Empty :- {}- | NonEmpty :- Text- >- )- → merge- { Empty =- λ ( _- : {}- )- → < NonEmpty =- _@2- | Empty :- {}- >- , NonEmpty =- λ ( _- : Text- )- → < NonEmpty =- _@2- ++ ","- ++ _- | Empty :- {}- >- }- _- : < Empty :- {}- | NonEmpty :- Text- >- )- < Empty =- {=}- | NonEmpty :- Text- >- )- : Text}- ''- ++ _+ >.NonEmpty+ "${element},${result}"+ }+ status+ )+ < Empty+ | NonEmpty :+ Text+ >.Empty+ )}+ ${y}'' ) ""
@@ -1,6 +1,11 @@-{ example0 = "-0.42"-, example1 = "13.37"-, example2 = "NaN"-, example3 = "Infinity"-, example4 = "-Infinity"+{ example0 =+ "-0.42"+, example1 =+ "13.37"+, example2 =+ "NaN"+, example3 =+ "Infinity"+, example4 =+ "-Infinity" }
@@ -0,0 +1,8 @@+let Role = < Wizard | Fighter | Rogue >++let show : Role → Text+ =+ λ(x : Role)+ → merge { Wizard = "Wizard", Fighter = "Fighter", Rogue = "Rogue" } x++in show Role.Wizard
@@ -0,0 +1,1 @@+"Wizard"
@@ -1,7 +1,7 @@ { example0 =- [ True, False ] : List Bool+ [ True, False ] , example1 =- [ True, False ] : List Bool+ [ True, False ] , example2 = λ(id : ∀(a : Type) → a → a) → id (List Bool) [ True, False ] }
@@ -1,9 +1,9 @@ { example0 =- [ 1 ] : Optional Natural+ Some 1 , example1 =- [ +1 ] : Optional Integer+ Some +1 , example2 =- λ(id : ∀(a : Type) → a → a) → id (Optional Bool) ([ True ] : Optional Bool)+ λ(id : ∀(a : Type) → a → a) → id (Optional Bool) (Some True) , example3 =- λ(a : Type) → λ(x : a) → [ x ] : Optional a+ λ(a : Type) → λ(x : a) → Some x }
@@ -1,1 +1,1 @@-[ "foo" ] : Optional Text+Some "foo"
@@ -1,6 +1,11 @@-{ example0 = λ(x : Bool) → x-, example1 = λ(x : Bool) → x-, example2 = λ(x : Bool) → False-, example3 = λ(x : Bool) → False-, example4 = λ(x : Bool) → x+{ example0 =+ λ(x : Bool) → x+, example1 =+ λ(x : Bool) → x+, example2 =+ λ(x : Bool) → False+, example3 =+ λ(x : Bool) → False+, example4 =+ λ(x : Bool) → x }
@@ -1,4 +1,7 @@-{ example0 = λ(x : Bool) → x-, example1 = λ(x : Bool) → x-, example2 = λ(x : Bool) → True+{ example0 =+ λ(x : Bool) → x+, example1 =+ λ(x : Bool) → x+, example2 =+ λ(x : Bool) → True }
@@ -1,3 +1,1 @@-{ example0 = λ(x : Bool) → x-, example1 = λ(x : Bool) → λ(y : Text) → y-}+{ example0 = λ(x : Bool) → x, example1 = λ(x : Bool) → λ(y : Text) → y }
@@ -1,4 +1,7 @@-{ example0 = λ(x : Bool) → x-, example1 = λ(x : Bool) → x-, example2 = λ(x : Bool) → False+{ example0 =+ λ(x : Bool) → x+, example1 =+ λ(x : Bool) → x+, example2 =+ λ(x : Bool) → False }
@@ -1,6 +1,11 @@-{ example0 = λ(x : Bool) → True-, example1 = λ(x : Bool) → True-, example2 = λ(x : Bool) → x-, example3 = λ(x : Bool) → x-, example4 = λ(x : Bool) → x+{ example0 =+ λ(x : Bool) → True+, example1 =+ λ(x : Bool) → True+, example2 =+ λ(x : Bool) → x+, example3 =+ λ(x : Bool) → x+, example4 =+ λ(x : Bool) → x }
@@ -0,0 +1,1 @@+Bool
@@ -0,0 +1,1 @@+Bool
@@ -0,0 +1,1 @@+Double
@@ -0,0 +1,1 @@+Double
@@ -0,0 +1,1 @@+1.2
@@ -0,0 +1,1 @@+1.2
@@ -0,0 +1,1 @@+Double/show
@@ -0,0 +1,1 @@+Double/show
@@ -0,0 +1,1 @@+Double/show 1.2
@@ -0,0 +1,1 @@+"1.2"
@@ -0,0 +1,1 @@+merge { x = 1, y = 2 } (< x | y >.x)
@@ -0,0 +1,1 @@+1
@@ -0,0 +1,1 @@+(λ(_ : X) → λ(_ : X) → _@1) x y
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+(λ(x : X) → y) x
@@ -0,0 +1,1 @@+y
@@ -0,0 +1,1 @@+(if True then a else b) (if True then y else z)
@@ -0,0 +1,1 @@+a y
@@ -0,0 +1,1 @@+(λ(x : X) → x) y
@@ -0,0 +1,1 @@+y
@@ -0,0 +1,1 @@+λ(_ : if True then X else Y) → if True then _ else y
@@ -0,0 +1,1 @@+λ(_ : X) → _
@@ -0,0 +1,1 @@+(if True then X else Y) → if True then A else B
@@ -0,0 +1,1 @@+X → A
@@ -0,0 +1,1 @@+if x then y else y
@@ -0,0 +1,1 @@+y
@@ -0,0 +1,1 @@+if False then 1 else 2
@@ -0,0 +1,1 @@+2
@@ -0,0 +1,1 @@+if if True then x else y then if True then a else b else if True then c else d
@@ -0,0 +1,1 @@+if x then a else c
@@ -0,0 +1,1 @@+if x then True else False
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+if True then 1 else 2
@@ -0,0 +1,1 @@+1
@@ -0,0 +1,1 @@+Integer
@@ -0,0 +1,1 @@+Integer
@@ -0,0 +1,1 @@+-1
@@ -0,0 +1,1 @@+-1
@@ -0,0 +1,1 @@++1
@@ -0,0 +1,1 @@++1
@@ -0,0 +1,1 @@+Integer/show -12
@@ -0,0 +1,1 @@+"-12"
@@ -0,0 +1,1 @@+Integer/show +12
@@ -0,0 +1,1 @@+"+12"
@@ -0,0 +1,1 @@+Integer/show
@@ -0,0 +1,1 @@+Integer/show
@@ -0,0 +1,1 @@+Integer/toDouble -12
@@ -0,0 +1,1 @@+-12.0
@@ -0,0 +1,1 @@+Integer/toDouble +12
@@ -0,0 +1,1 @@+12.0
@@ -0,0 +1,1 @@+Integer/toDouble
@@ -0,0 +1,1 @@+Integer/toDouble
@@ -0,0 +1,1 @@+Kind
@@ -0,0 +1,1 @@+Kind
@@ -0,0 +1,1 @@+let x = y in x
@@ -0,0 +1,1 @@+y
@@ -0,0 +1,1 @@+let x : A = y in x
@@ -0,0 +1,1 @@+y
@@ -0,0 +1,1 @@+List
@@ -0,0 +1,1 @@+List
@@ -0,0 +1,1 @@+List/build
@@ -0,0 +1,1 @@+List/build
@@ -0,0 +1,1 @@+List/build A (List/fold A x)
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+List/build A0 (λ(list : Type) → λ(cons : A0 → list → list) → λ(nil : list) → x)
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+List/fold
@@ -0,0 +1,1 @@+List/fold
@@ -0,0 +1,1 @@+List/fold A0 ([] : List A1) B g x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+List/fold A0 [ x ] B (λ(x : A0) → λ(y : B) → x) z
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+List/head
@@ -0,0 +1,1 @@+List/head
@@ -0,0 +1,1 @@+List/head T ([] : List T)
@@ -0,0 +1,1 @@+None T
@@ -0,0 +1,1 @@+List/head Natural [ 1 ]
@@ -0,0 +1,1 @@+Some 1
@@ -0,0 +1,1 @@+List/indexed
@@ -0,0 +1,1 @@+List/indexed
@@ -0,0 +1,1 @@+List/indexed T ([] : List T)
@@ -0,0 +1,1 @@+[] : List { index : Natural, value : T }
@@ -0,0 +1,1 @@+List/indexed Natural [ 1 ]
@@ -0,0 +1,1 @@+[ { index = 0, value = 1 } ]
@@ -0,0 +1,1 @@+List/last
@@ -0,0 +1,1 @@+List/last
@@ -0,0 +1,1 @@+List/last T ([] : List T)
@@ -0,0 +1,1 @@+None T
@@ -0,0 +1,1 @@+List/last Natural [ 1 ]
@@ -0,0 +1,1 @@+Some 1
@@ -0,0 +1,1 @@+List/length
@@ -0,0 +1,1 @@+List/length
@@ -0,0 +1,1 @@+List/length T ([] : List T)
@@ -0,0 +1,1 @@+0
@@ -0,0 +1,1 @@+List/length Natural [ 1 ]
@@ -0,0 +1,1 @@+1
@@ -0,0 +1,1 @@+[ if True then x else y ]
@@ -0,0 +1,1 @@+[ x ]
@@ -0,0 +1,1 @@+[] : List (if True then x else y)
@@ -0,0 +1,1 @@+[] : List x
@@ -0,0 +1,1 @@+List/reverse
@@ -0,0 +1,1 @@+List/reverse
@@ -0,0 +1,1 @@+List/reverse T ([] : List T)
@@ -0,0 +1,1 @@+[] : List T
@@ -0,0 +1,1 @@+List/reverse Natural [ 1, 2 ]
@@ -0,0 +1,1 @@+[ 2, 1 ]
@@ -0,0 +1,1 @@+merge { x = λ(_ : A) → _ } (< x : T >.x y)
@@ -0,0 +1,1 @@+y
@@ -0,0 +1,1 @@+merge { x = a } < x >.x
@@ -0,0 +1,1 @@+a
@@ -0,0 +1,1 @@+merge (if True then x else y) (if True then z else b)
@@ -0,0 +1,1 @@+merge x z
@@ -0,0 +1,1 @@+merge { x = λ(_ : A) → _ } < x = y > : A
@@ -0,0 +1,1 @@+y
@@ -0,0 +1,1 @@+merge (if True then x else y) (if True then z else b) : (if True then X else Y)
@@ -0,0 +1,1 @@+merge x z : X
@@ -0,0 +1,1 @@+Natural
@@ -0,0 +1,1 @@+Natural
@@ -0,0 +1,1 @@+Natural/build
@@ -0,0 +1,1 @@+Natural/build
@@ -0,0 +1,1 @@+Natural/build (Natural/fold x)
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,2 @@+Natural/build+(λ(natural : Type) → λ(succ : natural → natural) → λ(zero : natural) → x)
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+Natural/even
@@ -0,0 +1,1 @@+Natural/even
@@ -0,0 +1,1 @@+Natural/even 1
@@ -0,0 +1,1 @@+False
@@ -0,0 +1,1 @@+Natural/even 0
@@ -0,0 +1,1 @@+True
@@ -0,0 +1,1 @@+Natural/fold
@@ -0,0 +1,1 @@+Natural/fold
@@ -0,0 +1,1 @@+Natural/fold 1 Natural (λ(x : Natural) → x) x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+Natural/fold 0 B g x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+Natural/isZero
@@ -0,0 +1,1 @@+Natural/isZero
@@ -0,0 +1,1 @@+Natural/isZero 1
@@ -0,0 +1,1 @@+False
@@ -0,0 +1,1 @@+Natural/isZero 0
@@ -0,0 +1,1 @@+True
@@ -0,0 +1,1 @@+1
@@ -0,0 +1,1 @@+1
@@ -0,0 +1,1 @@+Natural/odd
@@ -0,0 +1,1 @@+Natural/odd
@@ -0,0 +1,1 @@+Natural/odd 1
@@ -0,0 +1,1 @@+True
@@ -0,0 +1,1 @@+Natural/odd 0
@@ -0,0 +1,1 @@+False
@@ -0,0 +1,1 @@+Natural/show
@@ -0,0 +1,1 @@+Natural/show
@@ -0,0 +1,1 @@+Natural/show 1
@@ -0,0 +1,1 @@+"1"
@@ -0,0 +1,1 @@+Natural/toInteger
@@ -0,0 +1,1 @@+Natural/toInteger
@@ -0,0 +1,1 @@+Natural/toInteger 1
@@ -0,0 +1,1 @@++1
@@ -0,0 +1,1 @@+None
@@ -0,0 +1,1 @@+None
@@ -0,0 +1,1 @@+[] : Optional Natural
@@ -0,0 +1,1 @@+None Natural
@@ -0,0 +1,1 @@+x && x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+False && x
@@ -0,0 +1,1 @@+False
@@ -0,0 +1,1 @@+True && x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+True && x && (True && y)
@@ -0,0 +1,1 @@+x && y
@@ -0,0 +1,1 @@+x && False
@@ -0,0 +1,1 @@+False
@@ -0,0 +1,1 @@+x && True
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+x == x
@@ -0,0 +1,1 @@+True
@@ -0,0 +1,1 @@+x == True
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+True == x == (True == y)
@@ -0,0 +1,1 @@+x == y
@@ -0,0 +1,1 @@+True == x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+x # ([] : List T)
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+[ x ] # [ y ]
@@ -0,0 +1,1 @@+[ x, y ]
@@ -0,0 +1,1 @@+([] : List T) # x # (([] : List T) # y)
@@ -0,0 +1,1 @@+x # y
@@ -0,0 +1,1 @@+([] : List T) # x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+x != x
@@ -0,0 +1,1 @@+False
@@ -0,0 +1,1 @@+False != x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+False != x != (False != y)
@@ -0,0 +1,1 @@+x != y
@@ -0,0 +1,1 @@+x != False
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+x || x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+False || x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+True || x
@@ -0,0 +1,1 @@+True
@@ -0,0 +1,1 @@+False || x || (False || y)
@@ -0,0 +1,1 @@+x || y
@@ -0,0 +1,1 @@+x || False
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+x || True
@@ -0,0 +1,1 @@+True
@@ -0,0 +1,1 @@+0 + x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+0 + x + (0 + y)
@@ -0,0 +1,1 @@+x + y
@@ -0,0 +1,1 @@+1 + 1
@@ -0,0 +1,1 @@+2
@@ -0,0 +1,1 @@+x + 0
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+"" ++ x
@@ -0,0 +1,1 @@+"${x}"
@@ -0,0 +1,1 @@+"hai" ++ x
@@ -0,0 +1,1 @@+"hai${x}"
@@ -0,0 +1,1 @@+"x" ++ "y"
@@ -0,0 +1,1 @@+"xy"
@@ -0,0 +1,1 @@+1 * x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+0 * x
@@ -0,0 +1,1 @@+0
@@ -0,0 +1,1 @@+1 * x * (1 * y)
@@ -0,0 +1,1 @@+x * y
@@ -0,0 +1,1 @@+x * 1
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+x * 0
@@ -0,0 +1,1 @@+0
@@ -0,0 +1,1 @@+2 * 2
@@ -0,0 +1,1 @@+4
@@ -0,0 +1,1 @@+Optional
@@ -0,0 +1,1 @@+Optional
@@ -0,0 +1,1 @@+Optional/build
@@ -0,0 +1,1 @@+Optional/build
@@ -0,0 +1,1 @@+Optional/build A0 (Optional/fold A1 x)
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,3 @@+Optional/build+A+(λ(optional : Type) → λ(just : A → optional) → λ(nothing : optional) → x)
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+Optional/fold
@@ -0,0 +1,1 @@+Optional/fold
@@ -0,0 +1,1 @@+Optional/fold A ([] : Optional A) B (λ(_ : A) → _) x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+Optional/fold A (Some x) B (λ(_ : A) → _) z
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+{ a : if True then y else z, b : x }
@@ -0,0 +1,1 @@+{ a : y, b : x }
@@ -0,0 +1,1 @@+{=}
@@ -0,0 +1,1 @@+{=}
@@ -0,0 +1,1 @@+{ x = a, y = b, z = c }.{ x, z }
@@ -0,0 +1,1 @@+{ x = a, z = c }
@@ -0,0 +1,1 @@+x.{}
@@ -0,0 +1,1 @@+{=}
@@ -0,0 +1,1 @@+(if True then y else z).{ x, y }
@@ -0,0 +1,1 @@+y.{ x, y }
@@ -0,0 +1,1 @@+{ x = v }.x
@@ -0,0 +1,1 @@+v
@@ -0,0 +1,1 @@+(if True then y else z).x
@@ -0,0 +1,1 @@+y.x
@@ -0,0 +1,1 @@+{ a : if True then A else B, b : T }
@@ -0,0 +1,1 @@+{ a : A, b : T }
@@ -0,0 +1,1 @@+{}
@@ -0,0 +1,1 @@+{}
@@ -0,0 +1,1 @@+{ x = { z = 1 } } ∧ { x = { y = 2 } }
@@ -0,0 +1,1 @@+{ x = { y = 2, z = 1 } }
@@ -0,0 +1,1 @@+{=} ∧ x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+{ x = { z = 1 } } ∧ { b = { y = 2 } }
@@ -0,0 +1,1 @@+{ b = { y = 2 }, x = { z = 1 } }
@@ -0,0 +1,1 @@+x ∧ {=} ∧ ({=} ∧ b)
@@ -0,0 +1,1 @@+x ∧ b
@@ -0,0 +1,1 @@+x ∧ {=}
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+{ x : { z : A } } ⩓ { x : { y : B } }
@@ -0,0 +1,1 @@+{ x : { y : B, z : A } }
@@ -0,0 +1,1 @@+{} ⩓ x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+{ x : { z : A } } ⩓ { b : { y : B } }
@@ -0,0 +1,1 @@+{ b : { y : B }, x : { z : A } }
@@ -0,0 +1,1 @@+x ⩓ {} ⩓ ({} ⩓ b)
@@ -0,0 +1,1 @@+x ⩓ b
@@ -0,0 +1,1 @@+x ⩓ {}
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+{ a : Kind } ⩓ { b : Kind }
@@ -0,0 +1,1 @@+{ a : Kind, b : Kind }
@@ -0,0 +1,1 @@+{ x = 1, y = 2 } ⫽ { x = 2 }
@@ -0,0 +1,1 @@+{ x = 2, y = 2 }
@@ -0,0 +1,1 @@+{=} ⫽ x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+{ x = 1, y = 2 } ⫽ { a = 2 }
@@ -0,0 +1,1 @@+{ a = 2, x = 1, y = 2 }
@@ -0,0 +1,1 @@+x ⫽ {=} ⫽ (y ⫽ {=})
@@ -0,0 +1,1 @@+x ⫽ y
@@ -0,0 +1,1 @@+x ⫽ {=}
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+Some (if True then x else y)
@@ -0,0 +1,1 @@+Some x
@@ -0,0 +1,1 @@+Sort
@@ -0,0 +1,1 @@+Sort
@@ -0,0 +1,1 @@+Text
@@ -0,0 +1,1 @@+Text
@@ -0,0 +1,1 @@+"s${"b${x}"}"
@@ -0,0 +1,1 @@+"sb${x}"
@@ -0,0 +1,1 @@+"s"
@@ -0,0 +1,1 @@+"s"
@@ -0,0 +1,1 @@+"s${if True then x else y}"
@@ -0,0 +1,1 @@+"s${x}"
@@ -0,0 +1,1 @@+Text/show
@@ -0,0 +1,1 @@+Text/show "\"\$\\\b\f\n\r\tツa\u0007b\u0010c"
@@ -0,0 +1,1 @@+"\"\\\"\\u0024\\\\\\b\\f\\n\\r\\tツa\\u0007b\\u0010c\""
@@ -0,0 +1,1 @@+Text/show
@@ -0,0 +1,1 @@+True
@@ -0,0 +1,1 @@+True
@@ -0,0 +1,1 @@+Type
@@ -0,0 +1,1 @@+x : A
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+Type
@@ -0,0 +1,1 @@+< x = y | y : if True then X else Y | z >
@@ -0,0 +1,1 @@+< x = y | y : X | z >
@@ -0,0 +1,1 @@+< x = if True then y else z >
@@ -0,0 +1,1 @@+< x = y >
@@ -0,0 +1,1 @@+< x : T >.x
@@ -0,0 +1,1 @@+< x : T >.x
@@ -0,0 +1,1 @@+< x = y | z | y : B >
@@ -0,0 +1,1 @@+< x = y | y : B | z >
@@ -0,0 +1,1 @@+< x : B | z >
@@ -0,0 +1,1 @@+< x : B | z >
@@ -0,0 +1,1 @@+<>
@@ -0,0 +1,1 @@+<>
@@ -0,0 +1,1 @@+< x : if True then B else Z | z >
@@ -0,0 +1,1 @@+< x : B | z >
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,1 @@+x
@@ -0,0 +1,6 @@+{-+ Builtin names are disallowed in bound variables.+ The grammar doesn't explicitely disallow this, but the implementation should+ refuse it. See the comments above the `nonreserved-label` rule.+-}+let Bool : Natural = 1 in Bool
@@ -0,0 +1,1 @@+Bool@2
@@ -0,0 +1,1 @@+f Some x
@@ -1,2 +0,0 @@--- Some operators require a space after them-[ 1 ]#[ 2 ]
@@ -1,1 +0,0 @@-https://example.com/foo as Text
@@ -1,1 +0,0 @@-öökexample.comcfooöö
@@ -0,0 +1,3 @@+let Prelude = https://prelude.dhall-lang.org/package.dhall++in Prelude.List.map
binary file changed (absent → 80 bytes)
@@ -1,1 +0,0 @@-"ABC"
@@ -1,1 +0,0 @@-cABC
@@ -1,5 +0,0 @@-[ env:FOO-- -- Yes, this is legal-, env:"\"\\\a\b\f\n\r\t\v"-]
binary file changed (38 → absent bytes)
@@ -1,1 +0,0 @@-"\\\"\$\\\/\b\f\n\r\t \u2200(a : Type) \u2192 a"
@@ -1,2 +0,0 @@-x\"$\/- â(a : Type) â a
@@ -1,4 +0,0 @@-''-''${-'''-''
@@ -1,2 +0,0 @@-f${-''
binary file changed (20 → 22 bytes)
@@ -0,0 +1,1 @@+https://example.com/foo as Text
@@ -0,0 +1,1 @@+öökexample.comcfooö
@@ -0,0 +1,5 @@+[ env:FOO++ -- Yes, this is legal+, env:"\"\\\a\b\f\n\r\t\v"+]
binary file changed (absent → 38 bytes)
@@ -0,0 +1,1 @@+./a.dhall sha256:16173e984d35ee3ffd8b6b79167df89480e67d1cd03ea5d0fc93689e4d928e61
binary file changed (absent → 87 bytes)
@@ -0,0 +1,1 @@+env:UNSET1 as Text ? env:UNSET2 ? missing ? env:UNSET3 ? 2
binary file changed (absent → 60 bytes)
@@ -0,0 +1,1 @@+https://raw.githubusercontent.com/dhall-lang/Prelude/c79c2bc3c46f129cc5b6d594ce298a381bcae92c/List/replicate using (./a.dhall sha256:16173e984d35ee3ffd8b6b79167df89480e67d1cd03ea5d0fc93689e4d928e61) sha256:b0e3ec1797b32c80c0bcb7e8254b08c7e9e35e75e6b410c7ac21477ab90167ad
binary file changed (absent → 270 bytes)
@@ -0,0 +1,3 @@+-- Verify that certain punctuation marks terminate paths correctly+ λ(x : ./example)+→ [./example, {bar = <baz = ./example>, qux = ./example}, ./example]
binary file changed (absent → 95 bytes)
@@ -0,0 +1,5 @@+[ /absolute/path+, ./relative/path+, ~/home/anchored/path+, /ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude+]
binary file changed (absent → 135 bytes)
@@ -0,0 +1,3 @@+{ example0 = /"foo"/bar/"baz qux"+, example1 = https://example.com/foo/"bar?baz"?qux+}
binary file changed (absent → 78 bytes)
@@ -0,0 +1,1 @@+./families/"禺.dhall"
binary file changed (absent → 25 bytes)
@@ -0,0 +1,14 @@+[ http://example.com/someFile.dhall+, https://john:doe@example.com:8080/foo/bar?qux=0#xyzzy+, http://prelude.dhall-lang.org/package.dhall+, https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude+, https://raw.githubusercontent.com/dhall-lang/dhall-haskell/18e4e9a18dc53271146df3ccf5b4177c3552236b/examples/True+, https://127.0.0.1/index.dhall+, https://[::]/index.dhall+, https://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/tutorial.dhall+, https://example.com/a%20b/c+, https://example.com/a+b/c++ -- Yes, this is legal+, https://-._~%2C!$&'()*+,;=:@-._~%2C!$&'()*+,;=:/foo?/-._~%2C!$&'()*+,;=:@/?+]
binary file changed (absent → 584 bytes)
@@ -1,1 +0,0 @@-env:UNSET1 as Text ? env:UNSET2 ? missing ? env:UNSET3 ? 2
binary file changed (60 → absent bytes)
@@ -1,1 +0,0 @@-"ABC${Natural/show 123}"
binary file changed (26 → absent bytes)
@@ -1,4 +0,0 @@-''-ABC-${Natural/show 123}-''
binary file changed (28 → absent bytes)
binary file changed (141 → 143 bytes)
binary file changed (20 → 22 bytes)
@@ -122,7 +122,7 @@ → merge { Empty = λ(_ : {})- → < NonEmpty =+ → < Empty : {} | NonEmpty : Text >.NonEmpty ( merge { AArch64_Linux = λ(_ : {}) → "aarch64-linux" , ARMv5tel_Linux =@@ -142,11 +142,10 @@ λ(_ : {}) → "x86_64-solaris" } element- | Empty : {}- >+ ) , NonEmpty = λ(result : Text)- → < NonEmpty =+ → < Empty : {} | NonEmpty : Text >.NonEmpty ( ( merge { AArch64_Linux = λ(_ : {}) → "aarch64-linux"@@ -177,13 +176,12 @@ ) ++ "," ++ result- | Empty : {}- >+ ) } status : < Empty : {} | NonEmpty : Text > )- < Empty = {=} | NonEmpty : Text >+ (< Empty : {} | NonEmpty : Text >.Empty {=}) ) : Text )@@ -206,17 +204,18 @@ → λ(status : < Empty : {} | NonEmpty : Text >) → merge { Empty =- λ(_ : {}) → < NonEmpty = element | Empty : {} >+ λ(_ : {}) →+ (< Empty : {} | NonEmpty : Text >.NonEmpty element) , NonEmpty = λ(result : Text)- → < NonEmpty = element ++ "," ++ result- | Empty : {}- >+ → < Empty : {} | NonEmpty : Text >.NonEmpty (+ element ++ "," ++ result+ ) } status : < Empty : {} | NonEmpty : Text > )- < Empty = {=} | NonEmpty : Text >+ (< Empty : {} | NonEmpty : Text >.Empty {=}) ) : Text )@@ -233,17 +232,18 @@ → λ(status : < Empty : {} | NonEmpty : Text >) → merge { Empty =- λ(_ : {}) → < NonEmpty = element | Empty : {} >+ λ(_ : {}) →+ < Empty : {} | NonEmpty : Text >.NonEmpty element , NonEmpty = λ(result : Text)- → < NonEmpty = element ++ "," ++ result- | Empty : {}- >+ → < Empty : {} | NonEmpty : Text >.NonEmpty (+ element ++ "," ++ result+ ) } status : < Empty : {} | NonEmpty : Text > )- < Empty = {=} | NonEmpty : Text >+ (< Empty : {} | NonEmpty : Text >.Empty {=}) ) : Text )
binary file changed (3678 → 3839 bytes)
binary file changed (27 → 29 bytes)
binary file changed (96 → 100 bytes)
@@ -0,0 +1,1 @@+merge x y z
binary file changed (absent → 16 bytes)
binary file changed (22 → 26 bytes)
@@ -1,2 +1,3 @@- { foo = (False && Natural/even (1 + 2 * 3)) || True == False != True }+ { foo = False && Natural/even (1 + 2 * 3) || True == False != True } ∧ { bar = [ "ABC" ++ "DEF" ] # [ "GHI" ] } ⫽ { baz = True }+: { foo : Bool, baz: Bool } ⩓ { bar : List Text }
binary file changed (104 → 150 bytes)
@@ -1,1 +0,0 @@-https://raw.githubusercontent.com/dhall-lang/Prelude/c79c2bc3c46f129cc5b6d594ce298a381bcae92c/List/replicate using (./a.dhall sha256:16173e984d35ee3ffd8b6b79167df89480e67d1cd03ea5d0fc93689e4d928e61) sha256:b0e3ec1797b32c80c0bcb7e8254b08c7e9e35e75e6b410c7ac21477ab90167ad
binary file changed (271 → absent bytes)
@@ -1,3 +0,0 @@--- Verify that certain punctuation marks terminate paths correctly- λ(x : ./example)-→ [./example, {bar = <baz = ./example>, qux = ./example}, ./example]
binary file changed (95 → absent bytes)
@@ -1,5 +0,0 @@-[ /absolute/path-, ./relative/path-, ~/home/anchored/path-, /ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude-]
binary file changed (135 → absent bytes)
@@ -0,0 +1,1 @@+(\(`Natural/even`: Natural -> Bool) -> `Natural/even`) Natural/odd 0
binary file changed (absent → 62 bytes)
binary file changed (75 → 81 bytes)
@@ -1,3 +0,0 @@-{ example0 = /"foo"/bar/"baz qux"-, example1 = https://example.com/foo/"bar?baz"?qux-}
binary file changed (79 → absent bytes)
binary file changed (42 → 44 bytes)
@@ -1,4 +0,0 @@-''-ABC-DEF-''
@@ -1,2 +0,0 @@-hABC-DEF
@@ -0,0 +1,6 @@+{-+This is always a type error, but if this+was a parse error it would be quite confusing+because Some looks like a builtin.+-}+Some x y z
binary file changed (absent → 17 bytes)
@@ -0,0 +1,11 @@+{- Fragment identifiers are not allowed in URLs because they serve no purpose+ for Dhall and they could lead to ambiguity if a parser interprets them as+ the list append operator (`#`)++ The following expression therefore only has one valid parse, which is to+ interpret the `#` as a list append. In other words, the following expression+ is parsed as:++ (https://example.com/foo) # bar+-}+https://example.com/foo#bar
binary file changed (absent → 33 bytes)
@@ -1,13 +0,0 @@- \(record : { name : Text- , value : Double- , taxed_value : Double- , in_ca : Bool- }- ) -> ''-Hello ${record.name}-You have just won ${Double/show record.value} dollars!-${ if record.in_ca- then "Well, ${Double/show record.taxed_value} dollars, after taxes"- else ""- }-''
binary file changed (236 → absent bytes)
@@ -0,0 +1,1 @@+"ABC"
@@ -0,0 +1,1 @@+cABC
@@ -0,0 +1,9 @@+-- Verify that an implementation is processing escape sequences correctly++''+''${+'''+$+"+\+''
@@ -0,0 +1,5 @@+l${+''+$+"+\
@@ -0,0 +1,1 @@+"\\\"\$\\\/\b\f\n\r\t \u2200(a : Type) \u2192 a"
@@ -0,0 +1,2 @@+x\"$\/+ â(a : Type) â a
@@ -0,0 +1,4 @@+''+''${+'''+''
@@ -0,0 +1,2 @@+f${+''
@@ -0,0 +1,7 @@+-- Non-trivial example that combines several multi-line literal features++λ(x : Text) → ''+ ${x} baz+ bar+ foo+ ''
binary file changed (absent → 42 bytes)
@@ -0,0 +1,16 @@+{- The indent is computed as the minimum number of leading spaces over all lines+ in a multi-line literal, including the line right before the closing quotes.+ In this case, there are three lines:++ * The first line containing " foo" with two leading spaces+ * The second line containing " bar" with two leading spaces+ * The third line containing "" with zero leading spaces++ Since the last line has zero leading spaces, the minimum number of leading+ spaces over all three lines is zero, so we don't strip any spaces.+-}++''+ foo+ bar+''
@@ -0,0 +1,2 @@+l foo+ bar
@@ -0,0 +1,1 @@+"ABC${Natural/show 123}"
binary file changed (absent → 26 bytes)
@@ -0,0 +1,4 @@+''+ABC+${Natural/show 123}+''
binary file changed (absent → 28 bytes)
@@ -0,0 +1,9 @@+{- This example verifies that an implementation is correctly breaking leading+ spaces at interpolated expressions. The first line has the fewest number of+ leading spaces (2) due to the interruption by the interpolated expression.+-}++''+${Natural/show 1} foo+ bar+''
binary file changed (absent → 38 bytes)
@@ -0,0 +1,8 @@+{- A comment within the interior of a multi-line literal counts as part of the+ literal+-}++''+-- Hello+{- world -}+''
@@ -0,0 +1,2 @@+u-- Hello+{- world -}
@@ -0,0 +1,6 @@+{- This is how you encode a multi-line literal that contains no newlines++ The leading newline is stripped+-}+''+foo''
@@ -0,0 +1,1 @@+cfoo
@@ -0,0 +1,4 @@+''+ABC+DEF+''
@@ -0,0 +1,2 @@+hABC+DEF
@@ -0,0 +1,13 @@+ \(record : { name : Text+ , value : Double+ , taxed_value : Double+ , in_ca : Bool+ }+ ) -> ''+Hello ${record.name}+You have just won ${Double/show record.value} dollars!+${ if record.in_ca+ then "Well, ${Double/show record.taxed_value} dollars, after taxes"+ else ""+ }+''
binary file changed (absent → 244 bytes)
@@ -0,0 +1,7 @@+{- Verify that an implementation is correctly preserving newlines in the+ corresponding double-quoted literal+-}++''+foo+bar''
@@ -0,0 +1,2 @@+gfoo+bar
@@ -0,0 +1,1 @@+"∀(a : Type) → a"
@@ -0,0 +1,1 @@+sâ(a : Type) â a
@@ -1,1 +0,0 @@-"∀(a : Type) → a"
@@ -1,1 +0,0 @@-sâ(a : Type) â a
@@ -1,1 +0,0 @@-./families/"禺.dhall"
binary file changed (25 → absent bytes)
@@ -1,12 +0,0 @@-[ http://example.com/someFile.dhall-, https://john:doe@example.com:8080/foo/bar?qux=0#xyzzy-, http://prelude.dhall-lang.org/package.dhall-, https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude-, https://raw.githubusercontent.com/dhall-lang/dhall-haskell/18e4e9a18dc53271146df3ccf5b4177c3552236b/examples/True-, https://127.0.0.1/index.dhall-, https://[::]/index.dhall-, https://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/tutorial.dhall-- -- Yes, this is legal-, https://-._~%2C!$&'()*+,;=:@-._~%2C!$&'()*+,;=:/foo?/-._~%2C!$&'()*+,;=:@/?#/-._~%2C!$&'()*+,;=:@/?-]
binary file changed (558 → absent bytes)
@@ -1,1 +1,1 @@-(../../../../../Prelude/package.dhall).`Bool`.and+../../../../../Prelude/Bool/and
@@ -1,1 +1,1 @@-(../../../../../Prelude/package.dhall).`Bool`.or+../../../../../Prelude/Bool/or
@@ -1,1 +1,1 @@-(../../../../../Prelude/package.dhall).`Bool`.even+../../../../../Prelude/Bool/even
@@ -1,1 +1,1 @@-(../../../../../Prelude/package.dhall).`Bool`.odd+../../../../../Prelude/Bool/odd
@@ -1,1 +1,1 @@-(../../../../../Prelude/package.dhall).`List`.concat+../../../../../Prelude/List/concat
@@ -1,1 +1,1 @@-(../../../../../Prelude/package.dhall).`List`.shifted+../../../../../Prelude/List/shifted
@@ -1,1 +1,1 @@-(../../../../../Prelude/package.dhall).`Natural`.sum+../../../../../Prelude/Natural/sum
@@ -1,1 +1,1 @@-(../../../../../Prelude/package.dhall).`Natural`.product+../../../../../Prelude/Natural/product
@@ -1,1 +1,1 @@-(../../../../../Prelude/package.dhall).`Optional`.head+../../../../../Prelude/Optional/head
@@ -1,1 +1,1 @@-(../../../../../Prelude/package.dhall).`Optional`.last+../../../../../Prelude/Optional/last
@@ -1,1 +1,1 @@-(../../../../../Prelude/package.dhall).`Text`.concat+../../../../../Prelude/Text/concat
@@ -1,5 +1,5 @@ Name: dhall-Version: 1.21.0+Version: 1.22.0 Cabal-Version: >=1.10 Build-Type: Simple Tested-With: GHC == 7.10.3, GHC == 8.4.3, GHC == 8.6.1@@ -25,6 +25,7 @@ Extra-Source-Files: benchmark/deep-nested-large-record/*.dhall benchmark/examples/*.dhall+ benchmark/examples/normalize/*.dhall CHANGELOG.md dhall-lang/Prelude/Bool/and dhall-lang/Prelude/Bool/build@@ -101,6 +102,8 @@ dhall-lang/Prelude/Text/concatSep dhall-lang/Prelude/Text/package.dhall dhall-lang/Prelude/Text/show+ dhall-lang/tests/import/data/*.txt+ dhall-lang/tests/import/data/*.dhall dhall-lang/tests/import/data/fieldOrder/*.dhall dhall-lang/tests/import/failure/*.dhall dhall-lang/tests/import/success/*.dhall@@ -109,7 +112,6 @@ dhall-lang/tests/normalization/success/haskell-tutorial/combineTypes/*.dhall dhall-lang/tests/normalization/success/haskell-tutorial/prefer/*.dhall dhall-lang/tests/normalization/success/haskell-tutorial/projection/*.dhall- dhall-lang/tests/normalization/success/multiline/*.dhall dhall-lang/tests/normalization/success/prelude/Bool/and/*.dhall dhall-lang/tests/normalization/success/prelude/Bool/and/*.dhall dhall-lang/tests/normalization/success/prelude/Bool/build/*.dhall@@ -230,9 +232,14 @@ dhall-lang/tests/normalization/success/prelude/Text/show/*.dhall dhall-lang/tests/normalization/success/simple/*.dhall dhall-lang/tests/normalization/success/simplifications/*.dhall+ dhall-lang/tests/normalization/success/unit/*.dhall dhall-lang/tests/parser/failure/*.dhall dhall-lang/tests/parser/success/*.dhall dhall-lang/tests/parser/success/*.dhallb+ dhall-lang/tests/parser/success/import/*.dhall+ dhall-lang/tests/parser/success/import/*.dhallb+ dhall-lang/tests/parser/success/text/*.dhall+ dhall-lang/tests/parser/success/text/*.dhallb dhall-lang/tests/typecheck/failure/*.dhall dhall-lang/tests/typecheck/success/*.dhall dhall-lang/tests/typecheck/success/prelude/Bool/and/*.dhall@@ -443,6 +450,7 @@ Dhall.Parser.Combinators, Dhall.Parser.Token, Dhall.Import.Types,+ Dhall.Eval, Dhall.Util, Paths_dhall if flag(with-http)@@ -485,8 +493,9 @@ dhall , directory , filepath ,+ foldl < 1.5 , prettyprinter ,- QuickCheck >= 2.10 && < 2.13,+ QuickCheck >= 2.10 && < 2.14, quickcheck-instances >= 0.3.12 && < 0.4 , serialise , tasty >= 0.11.2 && < 1.3 ,@@ -494,6 +503,7 @@ tasty-quickcheck >= 0.9.2 && < 0.11, text >= 0.11.1.0 && < 1.3 , transformers ,+ turtle < 1.6 , vector >= 0.11.0.0 && < 0.13 Default-Language: Haskell2010
@@ -147,10 +147,6 @@ -- $setup -- >>> :set -XOverloadedStrings -throws :: Exception e => Either e a -> IO a-throws (Left e) = Control.Exception.throwIO e-throws (Right r) = return r- {-| Every `Type` must obey the contract that if an expression's type matches the the `expected` type then the `extract` function must succeed. If not, then this exception is thrown@@ -185,8 +181,8 @@ where txt0 = Dhall.Util.insert invalidTypeExpected txt1 = Dhall.Util.insert invalidTypeExpression- + instance (Pretty s, Pretty a, Typeable s, Typeable a) => Exception (InvalidType s a) -- | @since 1.16@@ -231,7 +227,7 @@ -- | @since 1.16 data EvaluateSettings = EvaluateSettings { _startingContext :: Dhall.Context.Context (Expr Src X)- , _normalizer :: Dhall.Core.ReifiedNormalizer X+ , _normalizer :: Maybe (Dhall.Core.ReifiedNormalizer X) , _standardVersion :: StandardVersion } @@ -242,7 +238,7 @@ defaultEvaluateSettings :: EvaluateSettings defaultEvaluateSettings = EvaluateSettings { _startingContext = Dhall.Context.empty- , _normalizer = Dhall.Core.ReifiedNormalizer (const (pure Nothing))+ , _normalizer = Nothing , _standardVersion = Dhall.Binary.defaultStandardVersion } @@ -263,11 +259,11 @@ -- @since 1.16 normalizer :: (Functor f, HasEvaluateSettings s)- => LensLike' f s (Dhall.Core.ReifiedNormalizer X)+ => LensLike' f s (Maybe (Dhall.Core.ReifiedNormalizer X)) normalizer = evaluateSettings . l where l :: (Functor f)- => LensLike' f EvaluateSettings (Dhall.Core.ReifiedNormalizer X)+ => LensLike' f EvaluateSettings (Maybe (Dhall.Core.ReifiedNormalizer X)) l k s = fmap (\x -> s { _normalizer = x }) (k (_normalizer s)) -- | Access the standard version (used primarily when encoding or decoding@@ -336,7 +332,7 @@ -> IO a -- ^ The decoded value in Haskell inputWithSettings settings (Type {..}) txt = do- expr <- throws (Dhall.Parser.exprFromText (view sourceName settings) txt)+ expr <- Dhall.Core.throws (Dhall.Parser.exprFromText (view sourceName settings) txt) let InputSettings {..} = settings @@ -359,11 +355,9 @@ bytes' = bytes <> " : " <> suffix _ -> Annot expr' expected- _ <- throws (Dhall.TypeCheck.typeWith (view startingContext settings) annot)- let normExpr = Dhall.Core.normalizeWith- (Dhall.Core.getReifiedNormalizer- (view normalizer settings))- expr'+ _ <- Dhall.Core.throws (Dhall.TypeCheck.typeWith (view startingContext settings) annot)+ let normExpr = Dhall.Core.normalizeWith (view normalizer settings) expr'+ case extract normExpr of Just x -> return x Nothing -> Control.Exception.throwIO@@ -434,7 +428,7 @@ -> IO (Expr Src X) -- ^ The fully normalized AST inputExprWithSettings settings txt = do- expr <- throws (Dhall.Parser.exprFromText (view sourceName settings) txt)+ expr <- Dhall.Core.throws (Dhall.Parser.exprFromText (view sourceName settings) txt) let InputSettings {..} = settings @@ -449,8 +443,8 @@ expr' <- State.evalStateT (Dhall.Import.loadWith expr) status - _ <- throws (Dhall.TypeCheck.typeWith (view startingContext settings) expr')- pure (Dhall.Core.normalizeWith (Dhall.Core.getReifiedNormalizer (view normalizer settings)) expr')+ _ <- Dhall.Core.throws (Dhall.TypeCheck.typeWith (view startingContext settings) expr')+ pure (Dhall.Core.normalizeWith (view normalizer settings) expr') -- | Use this function to extract Haskell values directly from Dhall AST. -- The intended use case is to allow easy extraction of Dhall values for@@ -834,7 +828,7 @@ instance (Inject a, Interpret b) => Interpret (a -> b) where autoWith opts = Type extractOut expectedOut where- normalizer_ = Dhall.Core.getReifiedNormalizer (inputNormalizer opts)+ normalizer_ = Just (inputNormalizer opts) extractOut e = Just (\i -> case extractIn (Dhall.Core.normalizeWith normalizer_ (App e (embed i))) of Just o -> o@@ -909,7 +903,8 @@ expected = Union mempty -unsafeExpectUnion :: Text -> Expr Src X -> Dhall.Map.Map Text (Expr Src X)+unsafeExpectUnion+ :: Text -> Expr Src X -> Dhall.Map.Map Text (Maybe (Expr Src X)) unsafeExpectUnion _ (Union kts) = kts unsafeExpectUnion name expression =@@ -924,7 +919,9 @@ (name <> ": Unexpected constructor: " <> Dhall.Core.pretty expression) unsafeExpectUnionLit- :: Text -> Expr Src X -> (Text, Expr Src X, Dhall.Map.Map Text (Expr Src X))+ :: Text+ -> Expr Src X+ -> (Text, Expr Src X, Dhall.Map.Map Text (Maybe (Expr Src X))) unsafeExpectUnionLit _ (UnionLit k v kts) = (k, v, kts) unsafeExpectUnionLit name expression =@@ -938,6 +935,11 @@ Dhall.Core.internalError (name <> ": Unexpected constructor: " <> Dhall.Core.pretty expression) +possible :: Expr s a -> Maybe (Expr s a)+possible e = case e of+ RecordLit m | null m -> Nothing+ _ -> Just e+ instance (Constructor c1, Constructor c2, GenericInterpret f1, GenericInterpret f2) => GenericInterpret (M1 C c1 f1 :+: M1 C c2 f2) where genericAutoWith options@(InterpretOptions {..}) = pure (Type {..}) where@@ -957,7 +959,10 @@ extract _ = Nothing expected =- Union (Dhall.Map.fromList [(nameL, expectedL), (nameR, expectedR)])+ Union+ (Dhall.Map.fromList+ [(nameL, possible expectedL), (nameR, possible expectedR)]+ ) Type extractL expectedL = evalState (genericAutoWith options) 1 Type extractR expectedR = evalState (genericAutoWith options) 1@@ -976,7 +981,7 @@ extract _ = Nothing expected =- Union (Dhall.Map.insert name expectedR ktsL)+ Union (Dhall.Map.insert name (possible expectedR) ktsL) Type extractL expectedL = evalState (genericAutoWith options) 1 Type extractR expectedR = evalState (genericAutoWith options) 1@@ -997,7 +1002,7 @@ extract _ = Nothing expected =- Union (Dhall.Map.insert name expectedL ktsR)+ Union (Dhall.Map.insert name (possible expectedL) ktsR) Type extractL expectedL = evalState (genericAutoWith options) 1 Type extractR expectedR = evalState (genericAutoWith options) 1@@ -1248,13 +1253,22 @@ genericInjectWith options@(InterpretOptions {..}) = pure (InputType {..}) where embed (L1 (M1 l)) =- UnionLit keyL (embedL l) (Dhall.Map.singleton keyR declaredR)+ UnionLit+ keyL+ (embedL l)+ (Dhall.Map.singleton keyR (possible declaredR)) embed (R1 (M1 r)) =- UnionLit keyR (embedR r) (Dhall.Map.singleton keyL declaredL)+ UnionLit+ keyR+ (embedR r)+ (Dhall.Map.singleton keyL (possible declaredL)) declared =- Union (Dhall.Map.fromList [(keyL, declaredL), (keyR, declaredR)])+ Union+ (Dhall.Map.fromList+ [(keyL, possible declaredL), (keyR, possible declaredR)]+ ) nL :: M1 i c1 f1 a nL = undefined@@ -1272,7 +1286,10 @@ genericInjectWith options@(InterpretOptions {..}) = pure (InputType {..}) where embed (L1 l) =- UnionLit keyL valL (Dhall.Map.insert keyR declaredR ktsL')+ UnionLit+ keyL+ valL+ (Dhall.Map.insert keyR (possible declaredR) ktsL') where (keyL, valL, ktsL') = unsafeExpectUnionLit "genericInjectWith (:+:)" (embedL l)@@ -1283,7 +1300,7 @@ keyR = constructorModifier (Data.Text.pack (conName nR)) - declared = Union (Dhall.Map.insert keyR declaredR ktsL)+ declared = Union (Dhall.Map.insert keyR (possible declaredR) ktsL) InputType embedL declaredL = evalState (genericInjectWith options) 1 InputType embedR declaredR = evalState (genericInjectWith options) 1@@ -1295,7 +1312,10 @@ where embed (L1 (M1 l)) = UnionLit keyL (embedL l) ktsR embed (R1 r) =- UnionLit keyR valR (Dhall.Map.insert keyL declaredL ktsR')+ UnionLit+ keyR+ valR+ (Dhall.Map.insert keyL (possible declaredL) ktsR') where (keyR, valR, ktsR') = unsafeExpectUnionLit "genericInjectWith (:+:)" (embedR r)@@ -1305,7 +1325,7 @@ keyL = constructorModifier (Data.Text.pack (conName nL)) - declared = Union (Dhall.Map.insert keyL declaredL ktsR)+ declared = Union (Dhall.Map.insert keyL (possible declaredL) ktsR) InputType embedL declaredL = evalState (genericInjectWith options) 1 InputType embedR declaredR = evalState (genericInjectWith options) 1@@ -1513,11 +1533,12 @@ , expected = Union expect } where- expect = Dhall.expected <$> mp+ expect = (possible . Dhall.expected) <$> mp extractF e0 = do UnionLit fld e1 rest <- Just e0 t <- Dhall.Map.lookup fld mp- guard $ rest == Dhall.Map.delete fld expect+ guard $ Dhall.Core.Union rest `Dhall.Core.judgmentallyEqual`+ Dhall.Core.Union (Dhall.Map.delete fld expect) Dhall.extract t e1 -- | Parse a single constructor of a union@@ -1688,10 +1709,12 @@ InputType { embed = \x -> let (name, y) = embedF x- in UnionLit name y (Dhall.Map.delete name fields)+ in UnionLit name y (Dhall.Map.delete name fields') , declared =- Union fields+ Union fields' }+ where+ fields' = fmap possible fields inputConstructorWith :: Text
@@ -14,842 +14,867 @@ , renderStandardVersion -- * Encoding and decoding- , encode- , decode-- -- * Exceptions- , DecodingFailure(..)- ) where--import Codec.CBOR.Term (Term(..))-import Control.Applicative (empty, (<|>))-import Control.Exception (Exception)-import Dhall.Core- ( Binding(..)- , Chunks(..)- , Const(..)- , Directory(..)- , Expr(..)- , File(..)- , FilePrefix(..)- , Import(..)- , ImportHashed(..)- , ImportMode(..)- , ImportType(..)- , Scheme(..)- , URL(..)- , Var(..)- )--import Data.ByteArray.Encoding (Base(..))-import Data.Foldable (toList)-import Data.List.NonEmpty (NonEmpty(..))-import Data.Monoid ((<>))-import Data.Text (Text)-import Options.Applicative (Parser)-import Prelude hiding (exponent)-import GHC.Float (double2Float, float2Double)--import qualified Crypto.Hash-import qualified Data.ByteArray.Encoding-import qualified Data.ByteString-import qualified Data.Sequence-import qualified Data.Text-import qualified Data.Text.Encoding-import qualified Dhall.Map-import qualified Dhall.Set-import qualified Options.Applicative---- | Supported version strings-data StandardVersion- = NoVersion- -- ^ No version string- | V_5_0_0- -- ^ Version "5.0.0"- | V_4_0_0- -- ^ Version "4.0.0"- | V_3_0_0- -- ^ Version "3.0.0"- | V_2_0_0- -- ^ Version "2.0.0"- | V_1_0_0- -- ^ Version "1.0.0"- deriving (Enum, Bounded)--defaultStandardVersion :: StandardVersion-defaultStandardVersion = NoVersion--parseStandardVersion :: Parser StandardVersion-parseStandardVersion =- Options.Applicative.option readVersion- ( Options.Applicative.long "standard-version"- <> Options.Applicative.metavar "X.Y.Z"- <> Options.Applicative.help "The standard version to use"- <> Options.Applicative.value defaultStandardVersion- )- where- readVersion = do- string <- Options.Applicative.str- case string :: Text of- "none" -> return NoVersion- "1.0.0" -> return V_1_0_0- "2.0.0" -> return V_2_0_0- "3.0.0" -> return V_3_0_0- "4.0.0" -> return V_4_0_0- "5.0.0" -> return V_5_0_0- _ -> fail "Unsupported version"--renderStandardVersion :: StandardVersion -> Text-renderStandardVersion NoVersion = "none"-renderStandardVersion V_1_0_0 = "1.0.0"-renderStandardVersion V_2_0_0 = "2.0.0"-renderStandardVersion V_3_0_0 = "3.0.0"-renderStandardVersion V_4_0_0 = "4.0.0"-renderStandardVersion V_5_0_0 = "5.0.0"--{-| Convert a function applied to multiple arguments to the base function and- the list of arguments--}-unApply :: Expr s a -> (Expr s a, [Expr s a])-unApply e = (baseFunction₀, diffArguments₀ [])- where- ~(baseFunction₀, diffArguments₀) = go e-- go (App f a) = (baseFunction, diffArguments . (a :))- where- ~(baseFunction, diffArguments) = go f- go baseFunction = (baseFunction, id)---- | Encode a Dhall expression to a CBOR `Term`-encode :: Expr s Import -> Term-encode (Var (V "_" n)) =- TInteger n-encode (Var (V x 0)) =- TString x-encode (Var (V x n)) =- TList [ TString x, TInteger n ]-encode NaturalBuild =- TString "Natural/build"-encode NaturalFold =- TString "Natural/fold"-encode NaturalIsZero =- TString "Natural/isZero"-encode NaturalEven =- TString "Natural/even"-encode NaturalOdd =- TString "Natural/odd"-encode NaturalToInteger =- TString "Natural/toInteger"-encode NaturalShow =- TString "Natural/show"-encode IntegerToDouble =- TString "Integer/toDouble"-encode IntegerShow =- TString "Integer/show"-encode DoubleShow =- TString "Double/show"-encode ListBuild =- TString "List/build"-encode ListFold =- TString "List/fold"-encode ListLength =- TString "List/length"-encode ListHead =- TString "List/head"-encode ListLast =- TString "List/last"-encode ListIndexed =- TString "List/indexed"-encode ListReverse =- TString "List/reverse"-encode OptionalFold =- TString "Optional/fold"-encode OptionalBuild =- TString "Optional/build"-encode Bool =- TString "Bool"-encode Optional =- TString "Optional"-encode None =- TString "None"-encode Natural =- TString "Natural"-encode Integer =- TString "Integer"-encode Double =- TString "Double"-encode Text =- TString "Text"-encode TextShow =- TString "Text/show"-encode List =- TString "List"-encode (Const Type) =- TString "Type"-encode (Const Kind) =- TString "Kind"-encode (Const Sort) =- TString "Sort"-encode e@(App _ _) =- TList ([ TInt 0, f₁ ] ++ map encode arguments)- where- (f₀, arguments) = unApply e-- f₁ = encode f₀-encode (Lam "_" _A₀ b₀) =- TList [ TInt 1, _A₁, b₁ ]- where- _A₁ = encode _A₀- b₁ = encode b₀-encode (Lam x _A₀ b₀) =- TList [ TInt 1, TString x, _A₁, b₁ ]- where- _A₁ = encode _A₀- b₁ = encode b₀-encode (Pi "_" _A₀ _B₀) =- TList [ TInt 2, _A₁, _B₁ ]- where- _A₁ = encode _A₀- _B₁ = encode _B₀-encode (Pi x _A₀ _B₀) =- TList [ TInt 2, TString x, _A₁, _B₁ ]- where- _A₁ = encode _A₀- _B₁ = encode _B₀-encode (BoolOr l₀ r₀) =- TList [ TInt 3, TInt 0, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (BoolAnd l₀ r₀) =- TList [ TInt 3, TInt 1, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (BoolEQ l₀ r₀) =- TList [ TInt 3, TInt 2, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (BoolNE l₀ r₀) =- TList [ TInt 3, TInt 3, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (NaturalPlus l₀ r₀) =- TList [ TInt 3, TInt 4, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (NaturalTimes l₀ r₀) =- TList [ TInt 3, TInt 5, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (TextAppend l₀ r₀) =- TList [ TInt 3, TInt 6, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (ListAppend l₀ r₀) =- TList [ TInt 3, TInt 7, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (Combine l₀ r₀) =- TList [ TInt 3, TInt 8, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (Prefer l₀ r₀) =- TList [ TInt 3, TInt 9, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (CombineTypes l₀ r₀) =- TList [ TInt 3, TInt 10, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (ImportAlt l₀ r₀) =- TList [ TInt 3, TInt 11, l₁, r₁ ]- where- l₁ = encode l₀- r₁ = encode r₀-encode (ListLit _T₀ xs₀)- | null xs₀ = TList [ TInt 4, _T₁ ]- | otherwise = TList ([ TInt 4, TNull ] ++ xs₁)- where- _T₁ = case _T₀ of- Nothing -> TNull- Just t -> encode t-- xs₁ = map encode (Data.Foldable.toList xs₀)-encode (OptionalLit _T₀ Nothing) =- TList [ TInt 5, _T₁ ]- where- _T₁ = encode _T₀-encode (OptionalLit _T₀ (Just t₀)) =- TList [ TInt 5, _T₁, t₁ ]- where- _T₁ = encode _T₀- t₁ = encode t₀-encode (Some t₀) =- TList [ TInt 5, TNull, t₁ ]- where- t₁ = encode t₀-encode (Merge t₀ u₀ Nothing) =- TList [ TInt 6, t₁, u₁ ]- where- t₁ = encode t₀- u₁ = encode u₀-encode (Merge t₀ u₀ (Just _T₀)) =- TList [ TInt 6, t₁, u₁, _T₁ ]- where- t₁ = encode t₀- u₁ = encode u₀- _T₁ = encode _T₀-encode (Record xTs₀) =- TList [ TInt 7, TMap xTs₁ ]- where- xTs₁ = do- (x₀, _T₀) <- Dhall.Map.toList (Dhall.Map.sort xTs₀)- let x₁ = TString x₀- let _T₁ = encode _T₀- return (x₁, _T₁)-encode (RecordLit xts₀) =- TList [ TInt 8, TMap xts₁ ]- where- xts₁ = do- (x₀, t₀) <- Dhall.Map.toList (Dhall.Map.sort xts₀)- let x₁ = TString x₀- let t₁ = encode t₀- return (x₁, t₁)-encode (Field t₀ x) =- TList [ TInt 9, t₁, TString x ]- where- t₁ = encode t₀-encode (Project t₀ xs₀) =- TList ([ TInt 10, t₁ ] ++ xs₁)- where- t₁ = encode t₀- xs₁ = map TString (Dhall.Set.toList xs₀)-encode (Union xTs₀) =- TList [ TInt 11, TMap xTs₁ ]- where- xTs₁ = do- (x₀, _T₀) <- Dhall.Map.toList (Dhall.Map.sort xTs₀)- let x₁ = TString x₀- let _T₁ = encode _T₀- return (x₁, _T₁)-encode (UnionLit x t₀ yTs₀) =- TList [ TInt 12, TString x, t₁, TMap yTs₁ ]- where- t₁ = encode t₀-- yTs₁ = do- (y₀, _T₀) <- Dhall.Map.toList (Dhall.Map.sort yTs₀)- let y₁ = TString y₀- let _T₁ = encode _T₀- return (y₁, _T₁)-encode (BoolLit b) =- TBool b-encode (BoolIf t₀ l₀ r₀) =- TList [ TInt 14, t₁, l₁, r₁ ]- where- t₁ = encode t₀- l₁ = encode l₀- r₁ = encode r₀-encode (NaturalLit n) =- TList [ TInt 15, TInteger (fromIntegral n) ]-encode (IntegerLit n) =- TList [ TInt 16, TInteger n ]-encode (DoubleLit n64)- -- cborg always encodes NaN as "7e00"- | isNaN n64 = THalf n32- | useHalf = THalf n32- | useFloat = TFloat n32- | otherwise = TDouble n64- where- n32 = double2Float n64- useFloat = n64 == float2Double n32- -- the other three cases for Half-floats are 0.0 and the infinities- useHalf = or $ fmap (n64 ==) [0.0, infinity, -infinity]- infinity = 1/0 :: Double-encode (TextLit (Chunks xys₀ z₀)) =- TList ([ TInt 18 ] ++ xys₁ ++ [ z₁ ])- where- xys₁ = do- (x₀, y₀) <- xys₀- let x₁ = TString x₀- let y₁ = encode y₀- [ x₁, y₁ ]-- z₁ = TString z₀-encode (Embed x) =- importToTerm x-encode (Let as₀ b₀) =- TList ([ TInt 25 ] ++ as₁ ++ [ b₁ ])- where- as₁ = do- Binding x mA₀ a₀ <- toList as₀-- let mA₁ = case mA₀ of- Nothing -> TNull- Just _A₀ -> encode _A₀-- let a₁ = encode a₀-- [ TString x, mA₁, a₁ ]-- b₁ = encode b₀-encode (Annot t₀ _T₀) =- TList [ TInt 26, t₁, _T₁ ]- where- t₁ = encode t₀- _T₁ = encode _T₀-encode (Note _ e) =- encode e--importToTerm :: Import -> Term-importToTerm import_ =- case importType of- Remote (URL { scheme = scheme₀, ..}) ->- TList- ( prefix- ++ [ TInt scheme₁, using, TString authority ]- ++ map TString (reverse components)- ++ [ TString file ]- ++ (case query of Nothing -> [ TNull ]; Just q -> [ TString q ])- ++ (case fragment of Nothing -> [ TNull ]; Just f -> [ TString f ])- )- where- using = case headers of- Nothing ->- TNull- Just h ->- importToTerm- (Import { importHashed = h, importMode = Code })-- scheme₁ = case scheme₀ of- HTTP -> 0- HTTPS -> 1- File {..} = path-- Directory {..} = directory-- Local prefix₀ path ->- TList- ( prefix- ++ [ TInt prefix₁ ]- ++ map TString components₁- ++ [ TString file ]- )- where- File {..} = path-- Directory {..} = directory-- prefix₁ = case prefix₀ of- Absolute -> 2- Here -> 3- Parent -> 4- Home -> 5-- components₁ = reverse components-- Env x ->- TList (prefix ++ [ TInt 6, TString x ])-- Missing ->- TList (prefix ++ [ TInt 7 ])- where- prefix = [ TInt 24, h, m ]- where- h = case hash of- Nothing ->- TNull- Just digest ->- TList- [ TString "sha256", TString (Data.Text.pack (show digest)) ]-- m = TInt (case importMode of Code -> 0; RawText -> 1)-- Import {..} = import_-- ImportHashed {..} = importHashed--decodeMaybe :: Term -> Maybe (Expr s Import)-decodeMaybe (TInt n) =- return (Var (V "_" (fromIntegral n)))-decodeMaybe (TInteger n) =- return (Var (V "_" n))-decodeMaybe (TString "Natural/build") =- return NaturalBuild-decodeMaybe (TString "Natural/fold") =- return NaturalFold-decodeMaybe (TString "Natural/isZero") =- return NaturalIsZero-decodeMaybe (TString "Natural/even") =- return NaturalEven-decodeMaybe (TString "Natural/odd") =- return NaturalOdd-decodeMaybe (TString "Natural/toInteger") =- return NaturalToInteger-decodeMaybe (TString "Natural/show") =- return NaturalShow-decodeMaybe (TString "Integer/toDouble") =- return IntegerToDouble-decodeMaybe (TString "Integer/show") =- return IntegerShow-decodeMaybe (TString "Double/show") =- return DoubleShow-decodeMaybe (TString "List/build") =- return ListBuild-decodeMaybe (TString "List/fold") =- return ListFold-decodeMaybe (TString "List/length") =- return ListLength-decodeMaybe (TString "List/head") =- return ListHead-decodeMaybe (TString "List/last") =- return ListLast-decodeMaybe (TString "List/indexed") =- return ListIndexed-decodeMaybe (TString "List/reverse") =- return ListReverse-decodeMaybe (TString "Optional/fold") =- return OptionalFold-decodeMaybe (TString "Optional/build") =- return OptionalBuild-decodeMaybe (TString "Bool") =- return Bool-decodeMaybe (TString "Optional") =- return Optional-decodeMaybe (TString "None") =- return None-decodeMaybe (TString "Natural") =- return Natural-decodeMaybe (TString "Integer") =- return Integer-decodeMaybe (TString "Double") =- return Double-decodeMaybe (TString "Text") =- return Text-decodeMaybe (TString "Text/show") =- return TextShow-decodeMaybe (TString "List") =- return List-decodeMaybe (TString "Type") =- return (Const Type)-decodeMaybe (TString "Kind") =- return (Const Kind)-decodeMaybe (TString "Sort") =- return (Const Sort)-decodeMaybe (TString x) =- return (Var (V x 0))-decodeMaybe (TList [ TString x, TInt n ]) =- return (Var (V x (fromIntegral n)))-decodeMaybe (TList [ TString x, TInteger n ]) =- return (Var (V x n))-decodeMaybe (TList (TInt 0 : f₁ : xs₁)) = do- f₀ <- decodeMaybe f₁- xs₀ <- traverse decodeMaybe xs₁- return (foldl App f₀ xs₀)-decodeMaybe (TList [ TInt 1, _A₁, b₁ ]) = do- _A₀ <- decodeMaybe _A₁- b₀ <- decodeMaybe b₁- return (Lam "_" _A₀ b₀)-decodeMaybe (TList [ TInt 1, TString x, _A₁, b₁ ]) = do- _A₀ <- decodeMaybe _A₁- b₀ <- decodeMaybe b₁- return (Lam x _A₀ b₀)-decodeMaybe (TList [ TInt 2, _A₁, _B₁ ]) = do- _A₀ <- decodeMaybe _A₁- _B₀ <- decodeMaybe _B₁- return (Pi "_" _A₀ _B₀)-decodeMaybe (TList [ TInt 2, TString x, _A₁, _B₁ ]) = do- _A₀ <- decodeMaybe _A₁- _B₀ <- decodeMaybe _B₁- return (Pi x _A₀ _B₀)-decodeMaybe (TList [ TInt 3, TInt n, l₁, r₁ ]) = do- l₀ <- decodeMaybe l₁- r₀ <- decodeMaybe r₁- op <- case n of- 0 -> return BoolOr- 1 -> return BoolAnd- 2 -> return BoolEQ- 3 -> return BoolNE- 4 -> return NaturalPlus- 5 -> return NaturalTimes- 6 -> return TextAppend- 7 -> return ListAppend- 8 -> return Combine- 9 -> return Prefer- 10 -> return CombineTypes- 11 -> return ImportAlt- _ -> empty- return (op l₀ r₀)-decodeMaybe (TList [ TInt 4, _T₁ ]) = do- _T₀ <- decodeMaybe _T₁- return (ListLit (Just _T₀) empty)-decodeMaybe (TList (TInt 4 : TNull : xs₁ )) = do- xs₀ <- traverse decodeMaybe xs₁- return (ListLit Nothing (Data.Sequence.fromList xs₀))-decodeMaybe (TList [ TInt 5, _T₁ ]) = do- _T₀ <- decodeMaybe _T₁- return (OptionalLit _T₀ Nothing)-decodeMaybe (TList [ TInt 5, TNull, t₁ ]) = do- t₀ <- decodeMaybe t₁- return (Some t₀)-decodeMaybe (TList [ TInt 5, _T₁, t₁ ]) = do- _T₀ <- decodeMaybe _T₁- t₀ <- decodeMaybe t₁- return (OptionalLit _T₀ (Just t₀))-decodeMaybe (TList [ TInt 6, t₁, u₁ ]) = do- t₀ <- decodeMaybe t₁- u₀ <- decodeMaybe u₁- return (Merge t₀ u₀ Nothing)-decodeMaybe (TList [ TInt 6, t₁, u₁, _T₁ ]) = do- t₀ <- decodeMaybe t₁- u₀ <- decodeMaybe u₁- _T₀ <- decodeMaybe _T₁- return (Merge t₀ u₀ (Just _T₀))-decodeMaybe (TList [ TInt 7, TMap xTs₁ ]) = do- let process (TString x, _T₁) = do- _T₀ <- decodeMaybe _T₁-- return (x, _T₀)- process _ =- empty-- xTs₀ <- traverse process xTs₁-- return (Record (Dhall.Map.fromList xTs₀))-decodeMaybe (TList [ TInt 8, TMap xts₁ ]) = do- let process (TString x, t₁) = do- t₀ <- decodeMaybe t₁-- return (x, t₀)- process _ =- empty-- xts₀ <- traverse process xts₁-- return (RecordLit (Dhall.Map.fromList xts₀))-decodeMaybe (TList [ TInt 9, t₁, TString x ]) = do- t₀ <- decodeMaybe t₁-- return (Field t₀ x)-decodeMaybe (TList (TInt 10 : t₁ : xs₁)) = do- t₀ <- decodeMaybe t₁-- let process (TString x) = return x- process _ = empty-- xs₀ <- traverse process xs₁-- return (Project t₀ (Dhall.Set.fromList xs₀))-decodeMaybe (TList [ TInt 11, TMap xTs₁ ]) = do- let process (TString x, _T₁) = do- _T₀ <- decodeMaybe _T₁-- return (x, _T₀)- process _ =- empty-- xTs₀ <- traverse process xTs₁-- return (Union (Dhall.Map.fromList xTs₀))-decodeMaybe (TList [ TInt 12, TString x, t₁, TMap yTs₁ ]) = do- t₀ <- decodeMaybe t₁-- let process (TString y, _T₁) = do- _T₀ <- decodeMaybe _T₁-- return (y, _T₀)- process _ =- empty-- yTs₀ <- traverse process yTs₁-- return (UnionLit x t₀ (Dhall.Map.fromList yTs₀))-decodeMaybe (TBool b) = do- return (BoolLit b)-decodeMaybe (TList [ TInt 14, t₁, l₁, r₁ ]) = do- t₀ <- decodeMaybe t₁- l₀ <- decodeMaybe l₁- r₀ <- decodeMaybe r₁-- return (BoolIf t₀ l₀ r₀)-decodeMaybe (TList [ TInt 15, TInt n ]) = do- return (NaturalLit (fromIntegral n))-decodeMaybe (TList [ TInt 15, TInteger n ]) = do- return (NaturalLit (fromInteger n))-decodeMaybe (TList [ TInt 16, TInt n ]) = do- return (IntegerLit (fromIntegral n))-decodeMaybe (TList [ TInt 16, TInteger n ]) = do- return (IntegerLit n)-decodeMaybe (THalf n) = do- return (DoubleLit (float2Double n))-decodeMaybe (TFloat n) = do- return (DoubleLit (float2Double n))-decodeMaybe (TDouble n) = do- return (DoubleLit n)-decodeMaybe (TList (TInt 18 : xs)) = do- let process (TString x : y₁ : zs) = do- y₀ <- decodeMaybe y₁-- ~(xys, z) <- process zs-- return ((x, y₀) : xys, z)- process [ TString z ] = do- return ([], z)- process _ = do- empty-- (xys, z) <- process xs-- return (TextLit (Chunks xys z))-decodeMaybe (TList (TInt 24 : h : TInt mode : TInt n : xs)) = do- hash <- case h of- TNull -> do- return Nothing-- TList [ TString "sha256", TString base16Text ] -> do- let base16Bytes = Data.Text.Encoding.encodeUtf8 base16Text- digestBytes <- case Data.ByteArray.Encoding.convertFromBase Base16 base16Bytes of- Left _ -> empty- Right digestBytes -> return (digestBytes :: Data.ByteString.ByteString)-- digest <- Crypto.Hash.digestFromByteString digestBytes- return (Just digest)-- _ -> do- empty-- importMode <- case mode of- 0 -> return Code- 1 -> return RawText- _ -> empty-- let remote scheme = do- let process [ TString file, q, f ] = do- query <- case q of- TNull -> return Nothing- TString x -> return (Just x)- _ -> empty- fragment <- case f of- TNull -> return Nothing- TString x -> return (Just x)- _ -> empty- return ([], file, query, fragment)- process (TString path : ys) = do- (paths, file, query, fragment) <- process ys- return (path : paths, file, query, fragment)- process _ = do- empty-- (headers, authority, paths, file, query, fragment) <- case xs of- headers₀ : TString authority : ys -> do- headers₁ <- case headers₀ of- TNull -> return Nothing- _ -> do- Embed (Import { importHashed = headers }) <- decodeMaybe headers₀- return (Just headers)- (paths, file, query, fragment) <- process ys- return (headers₁, authority, paths, file, query, fragment)- _ -> do- empty-- let components = reverse paths- let directory = Directory {..}- let path = File {..}-- return (Remote (URL {..}))-- let local prefix = do- let process [ TString file ] = do- return ([], file)- process (TString path : ys) = do- (paths, file) <- process ys- return (path : paths, file)- process _ =- empty-- (paths, file) <- process xs-- let components = reverse paths- let directory = Directory {..}-- return (Local prefix (File {..}))-- let env = do- case xs of- [ TString x ] -> return (Env x)- _ -> empty-- let missing = return Missing-- importType <- case n of- 0 -> remote HTTP- 1 -> remote HTTPS- 2 -> local Absolute- 3 -> local Here- 4 -> local Parent- 5 -> local Home- 6 -> env- 7 -> missing- _ -> empty-- let importHashed = ImportHashed {..}-- return (Embed (Import {..}))-decodeMaybe (TList (TInt 25 : xs)) = do- let process (TString x : _A₁ : a₁ : ls₁) = do- mA₀ <- case _A₁ of- TNull -> return Nothing- _ -> fmap Just (decodeMaybe _A₁)-- a₀ <- decodeMaybe a₁-- let binding = Binding x mA₀ a₀-- case ls₁ of- [ b₁ ] -> do- b₀ <- decodeMaybe b₁-- return (Let (binding :| []) b₀)- _ -> do- Let (l₀ :| ls₀) b₀ <- process ls₁-- return (Let (binding :| (l₀ : ls₀)) b₀)- process _ = do- empty-- process xs-decodeMaybe (TList [ TInt 26, t₁, _T₁ ]) = do- t₀ <- decodeMaybe t₁- _T₀ <- decodeMaybe _T₁- return (Annot t₀ _T₀)-decodeMaybe _ =- empty---- | Decode a Dhall expression from a CBOR `Term`-decode :: Term -> Either DecodingFailure (Expr s Import)-decode term =- case decodeWithoutVersion <|> decodeWithVersion of- Just expression -> Right expression- Nothing -> Left (CBORIsNotDhall term)- where- -- This is the behavior specified by the standard- decodeWithoutVersion = decodeMaybe term-- -- For backwards compatibility with older expressions that have a version- -- tag to ease the migration- decodeWithVersion = do- TList [ TString _, taggedTerm ] <- return term- decodeMaybe taggedTerm+ , ToTerm(..)+ , FromTerm(..)+ , encodeExpression+ , decodeExpression++ -- * Exceptions+ , DecodingFailure(..)+ ) where++import Codec.CBOR.Term (Term(..))+import Control.Applicative (empty, (<|>))+import Control.Exception (Exception)+import Dhall.Core+ ( Binding(..)+ , Chunks(..)+ , Const(..)+ , Directory(..)+ , Expr(..)+ , File(..)+ , FilePrefix(..)+ , Import(..)+ , ImportHashed(..)+ , ImportMode(..)+ , ImportType(..)+ , Scheme(..)+ , URL(..)+ , Var(..)+ )++import Data.ByteArray.Encoding (Base(..))+import Data.Foldable (toList)+import Data.List.NonEmpty (NonEmpty(..))+import Data.Monoid ((<>))+import Data.Text (Text)+import Options.Applicative (Parser)+import Prelude hiding (exponent)+import GHC.Float (double2Float, float2Double)++import qualified Crypto.Hash+import qualified Data.ByteArray.Encoding+import qualified Data.ByteString+import qualified Data.Sequence+import qualified Data.Text+import qualified Data.Text.Encoding+import qualified Dhall.Map+import qualified Dhall.Set+import qualified Options.Applicative++-- | Supported version strings+data StandardVersion+ = NoVersion+ -- ^ No version string+ | V_5_0_0+ -- ^ Version "5.0.0"+ | V_4_0_0+ -- ^ Version "4.0.0"+ | V_3_0_0+ -- ^ Version "3.0.0"+ | V_2_0_0+ -- ^ Version "2.0.0"+ | V_1_0_0+ -- ^ Version "1.0.0"+ deriving (Enum, Bounded)++defaultStandardVersion :: StandardVersion+defaultStandardVersion = NoVersion++parseStandardVersion :: Parser StandardVersion+parseStandardVersion =+ Options.Applicative.option readVersion+ ( Options.Applicative.long "standard-version"+ <> Options.Applicative.metavar "X.Y.Z"+ <> Options.Applicative.help "The standard version to use"+ <> Options.Applicative.value defaultStandardVersion+ )+ where+ readVersion = do+ string <- Options.Applicative.str+ case string :: Text of+ "none" -> return NoVersion+ "1.0.0" -> return V_1_0_0+ "2.0.0" -> return V_2_0_0+ "3.0.0" -> return V_3_0_0+ "4.0.0" -> return V_4_0_0+ "5.0.0" -> return V_5_0_0+ _ -> fail "Unsupported version"++renderStandardVersion :: StandardVersion -> Text+renderStandardVersion NoVersion = "none"+renderStandardVersion V_1_0_0 = "1.0.0"+renderStandardVersion V_2_0_0 = "2.0.0"+renderStandardVersion V_3_0_0 = "3.0.0"+renderStandardVersion V_4_0_0 = "4.0.0"+renderStandardVersion V_5_0_0 = "5.0.0"++{-| Convert a function applied to multiple arguments to the base function and+ the list of arguments+-}+unApply :: Expr s a -> (Expr s a, [Expr s a])+unApply e₀ = (baseFunction₀, diffArguments₀ [])+ where+ ~(baseFunction₀, diffArguments₀) = go e₀++ go (App f a) = (baseFunction, diffArguments . (a :))+ where+ ~(baseFunction, diffArguments) = go f++ go (Note _ e) = go e++ go baseFunction = (baseFunction, id)++-- | Types that can be encoded as a CBOR `Term`+class ToTerm a where+ encode :: a -> Term++instance ToTerm a => ToTerm (Expr s a) where+ encode (Var (V "_" n)) =+ TInteger n+ encode (Var (V x n)) =+ TList [ TString x, TInteger n ]+ encode NaturalBuild =+ TString "Natural/build"+ encode NaturalFold =+ TString "Natural/fold"+ encode NaturalIsZero =+ TString "Natural/isZero"+ encode NaturalEven =+ TString "Natural/even"+ encode NaturalOdd =+ TString "Natural/odd"+ encode NaturalToInteger =+ TString "Natural/toInteger"+ encode NaturalShow =+ TString "Natural/show"+ encode IntegerToDouble =+ TString "Integer/toDouble"+ encode IntegerShow =+ TString "Integer/show"+ encode DoubleShow =+ TString "Double/show"+ encode ListBuild =+ TString "List/build"+ encode ListFold =+ TString "List/fold"+ encode ListLength =+ TString "List/length"+ encode ListHead =+ TString "List/head"+ encode ListLast =+ TString "List/last"+ encode ListIndexed =+ TString "List/indexed"+ encode ListReverse =+ TString "List/reverse"+ encode OptionalFold =+ TString "Optional/fold"+ encode OptionalBuild =+ TString "Optional/build"+ encode Bool =+ TString "Bool"+ encode Optional =+ TString "Optional"+ encode None =+ TString "None"+ encode Natural =+ TString "Natural"+ encode Integer =+ TString "Integer"+ encode Double =+ TString "Double"+ encode Text =+ TString "Text"+ encode TextShow =+ TString "Text/show"+ encode List =+ TString "List"+ encode (Const Type) =+ TString "Type"+ encode (Const Kind) =+ TString "Kind"+ encode (Const Sort) =+ TString "Sort"+ encode e@(App _ _) =+ TList ([ TInt 0, f₁ ] ++ map encode arguments)+ where+ (f₀, arguments) = unApply e++ f₁ = encode f₀+ encode (Lam "_" _A₀ b₀) =+ TList [ TInt 1, _A₁, b₁ ]+ where+ _A₁ = encode _A₀+ b₁ = encode b₀+ encode (Lam x _A₀ b₀) =+ TList [ TInt 1, TString x, _A₁, b₁ ]+ where+ _A₁ = encode _A₀+ b₁ = encode b₀+ encode (Pi "_" _A₀ _B₀) =+ TList [ TInt 2, _A₁, _B₁ ]+ where+ _A₁ = encode _A₀+ _B₁ = encode _B₀+ encode (Pi x _A₀ _B₀) =+ TList [ TInt 2, TString x, _A₁, _B₁ ]+ where+ _A₁ = encode _A₀+ _B₁ = encode _B₀+ encode (BoolOr l₀ r₀) =+ TList [ TInt 3, TInt 0, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (BoolAnd l₀ r₀) =+ TList [ TInt 3, TInt 1, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (BoolEQ l₀ r₀) =+ TList [ TInt 3, TInt 2, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (BoolNE l₀ r₀) =+ TList [ TInt 3, TInt 3, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (NaturalPlus l₀ r₀) =+ TList [ TInt 3, TInt 4, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (NaturalTimes l₀ r₀) =+ TList [ TInt 3, TInt 5, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (TextAppend l₀ r₀) =+ TList [ TInt 3, TInt 6, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (ListAppend l₀ r₀) =+ TList [ TInt 3, TInt 7, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (Combine l₀ r₀) =+ TList [ TInt 3, TInt 8, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (Prefer l₀ r₀) =+ TList [ TInt 3, TInt 9, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (CombineTypes l₀ r₀) =+ TList [ TInt 3, TInt 10, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (ImportAlt l₀ r₀) =+ TList [ TInt 3, TInt 11, l₁, r₁ ]+ where+ l₁ = encode l₀+ r₁ = encode r₀+ encode (ListLit _T₀ xs₀)+ | null xs₀ = TList [ TInt 4, _T₁ ]+ | otherwise = TList ([ TInt 4, TNull ] ++ xs₁)+ where+ _T₁ = case _T₀ of+ Nothing -> TNull+ Just t -> encode t++ xs₁ = map encode (Data.Foldable.toList xs₀)+ encode (OptionalLit _T₀ Nothing) =+ TList [ TInt 5, _T₁ ]+ where+ _T₁ = encode _T₀+ encode (OptionalLit _T₀ (Just t₀)) =+ TList [ TInt 5, _T₁, t₁ ]+ where+ _T₁ = encode _T₀+ t₁ = encode t₀+ encode (Some t₀) =+ TList [ TInt 5, TNull, t₁ ]+ where+ t₁ = encode t₀+ encode (Merge t₀ u₀ Nothing) =+ TList [ TInt 6, t₁, u₁ ]+ where+ t₁ = encode t₀+ u₁ = encode u₀+ encode (Merge t₀ u₀ (Just _T₀)) =+ TList [ TInt 6, t₁, u₁, _T₁ ]+ where+ t₁ = encode t₀+ u₁ = encode u₀+ _T₁ = encode _T₀+ encode (Record xTs₀) =+ TList [ TInt 7, TMap xTs₁ ]+ where+ xTs₁ = do+ (x₀, _T₀) <- Dhall.Map.toList (Dhall.Map.sort xTs₀)+ let x₁ = TString x₀+ let _T₁ = encode _T₀+ return (x₁, _T₁)+ encode (RecordLit xts₀) =+ TList [ TInt 8, TMap xts₁ ]+ where+ xts₁ = do+ (x₀, t₀) <- Dhall.Map.toList (Dhall.Map.sort xts₀)+ let x₁ = TString x₀+ let t₁ = encode t₀+ return (x₁, t₁)+ encode (Field t₀ x) =+ TList [ TInt 9, t₁, TString x ]+ where+ t₁ = encode t₀+ encode (Project t₀ xs₀) =+ TList ([ TInt 10, t₁ ] ++ xs₁)+ where+ t₁ = encode t₀+ xs₁ = map TString (Dhall.Set.toList xs₀)+ encode (Union xTs₀) =+ TList [ TInt 11, TMap xTs₁ ]+ where+ xTs₁ = do+ (x₀, mT₀) <- Dhall.Map.toList (Dhall.Map.sort xTs₀)++ let x₁ = TString x₀++ let _T₁ = case mT₀ of+ Nothing -> TNull+ Just _T₀ -> encode _T₀++ return (x₁, _T₁)+ encode (UnionLit x t₀ yTs₀) =+ TList [ TInt 12, TString x, t₁, TMap yTs₁ ]+ where+ t₁ = encode t₀++ yTs₁ = do+ (y₀, mT₀) <- Dhall.Map.toList (Dhall.Map.sort yTs₀)+ let y₁ = TString y₀+ let _T₁ = case mT₀ of+ Just _T₀ -> encode _T₀+ Nothing -> TNull+ return (y₁, _T₁)+ encode (BoolLit b) =+ TBool b+ encode (BoolIf t₀ l₀ r₀) =+ TList [ TInt 14, t₁, l₁, r₁ ]+ where+ t₁ = encode t₀+ l₁ = encode l₀+ r₁ = encode r₀+ encode (NaturalLit n) =+ TList [ TInt 15, TInteger (fromIntegral n) ]+ encode (IntegerLit n) =+ TList [ TInt 16, TInteger n ]+ encode (DoubleLit n64)+ -- cborg always encodes NaN as "7e00"+ | isNaN n64 = THalf n32+ | useHalf = THalf n32+ | useFloat = TFloat n32+ | otherwise = TDouble n64+ where+ n32 = double2Float n64+ useFloat = n64 == float2Double n32+ -- the other three cases for Half-floats are 0.0 and the infinities+ useHalf = or $ fmap (n64 ==) [0.0, infinity, -infinity]+ infinity = 1/0 :: Double+ encode (TextLit (Chunks xys₀ z₀)) =+ TList ([ TInt 18 ] ++ xys₁ ++ [ z₁ ])+ where+ xys₁ = do+ (x₀, y₀) <- xys₀+ let x₁ = TString x₀+ let y₁ = encode y₀+ [ x₁, y₁ ]++ z₁ = TString z₀+ encode (Embed x) =+ encode x+ encode (Let as₀ b₀) =+ TList ([ TInt 25 ] ++ as₁ ++ [ b₁ ])+ where+ as₁ = do+ Binding x mA₀ a₀ <- toList as₀++ let mA₁ = case mA₀ of+ Nothing -> TNull+ Just _A₀ -> encode _A₀++ let a₁ = encode a₀++ [ TString x, mA₁, a₁ ]++ b₁ = encode b₀+ encode (Annot t₀ _T₀) =+ TList [ TInt 26, t₁, _T₁ ]+ where+ t₁ = encode t₀+ _T₁ = encode _T₀+ encode (Note _ e) =+ encode e++instance ToTerm Import where+ encode import_ =+ case importType of+ Remote (URL { scheme = scheme₀, ..}) ->+ TList+ ( prefix+ ++ [ TInt scheme₁, using, TString authority ]+ ++ map TString (reverse components)+ ++ [ TString file ]+ ++ (case query of Nothing -> [ TNull ]; Just q -> [ TString q ])+ )+ where+ using = case headers of+ Nothing ->+ TNull+ Just h ->+ encode+ (Import { importHashed = h, importMode = Code })++ scheme₁ = case scheme₀ of+ HTTP -> 0+ HTTPS -> 1+ File {..} = path++ Directory {..} = directory++ Local prefix₀ path ->+ TList+ ( prefix+ ++ [ TInt prefix₁ ]+ ++ map TString components₁+ ++ [ TString file ]+ )+ where+ File {..} = path++ Directory {..} = directory++ prefix₁ = case prefix₀ of+ Absolute -> 2+ Here -> 3+ Parent -> 4+ Home -> 5++ components₁ = reverse components++ Env x ->+ TList (prefix ++ [ TInt 6, TString x ])++ Missing ->+ TList (prefix ++ [ TInt 7 ])+ where+ prefix = [ TInt 24, h, m ]+ where+ h = case hash of+ Nothing ->+ TNull+ Just digest ->+ TList+ [ TString "sha256", TString (Data.Text.pack (show digest)) ]++ m = TInt (case importMode of Code -> 0; RawText -> 1)++ Import {..} = import_++ ImportHashed {..} = importHashed++-- | Types that can be decoded from a CBOR `Term`+class FromTerm a where+ decode :: Term -> Maybe a++instance FromTerm a => FromTerm (Expr s a) where+ decode (TInt n) =+ return (Var (V "_" (fromIntegral n)))+ decode (TInteger n) =+ return (Var (V "_" n))+ decode (TString "Natural/build") =+ return NaturalBuild+ decode (TString "Natural/fold") =+ return NaturalFold+ decode (TString "Natural/isZero") =+ return NaturalIsZero+ decode (TString "Natural/even") =+ return NaturalEven+ decode (TString "Natural/odd") =+ return NaturalOdd+ decode (TString "Natural/toInteger") =+ return NaturalToInteger+ decode (TString "Natural/show") =+ return NaturalShow+ decode (TString "Integer/toDouble") =+ return IntegerToDouble+ decode (TString "Integer/show") =+ return IntegerShow+ decode (TString "Double/show") =+ return DoubleShow+ decode (TString "List/build") =+ return ListBuild+ decode (TString "List/fold") =+ return ListFold+ decode (TString "List/length") =+ return ListLength+ decode (TString "List/head") =+ return ListHead+ decode (TString "List/last") =+ return ListLast+ decode (TString "List/indexed") =+ return ListIndexed+ decode (TString "List/reverse") =+ return ListReverse+ decode (TString "Optional/fold") =+ return OptionalFold+ decode (TString "Optional/build") =+ return OptionalBuild+ decode (TString "Bool") =+ return Bool+ decode (TString "Optional") =+ return Optional+ decode (TString "None") =+ return None+ decode (TString "Natural") =+ return Natural+ decode (TString "Integer") =+ return Integer+ decode (TString "Double") =+ return Double+ decode (TString "Text") =+ return Text+ decode (TString "Text/show") =+ return TextShow+ decode (TString "List") =+ return List+ decode (TString "Type") =+ return (Const Type)+ decode (TString "Kind") =+ return (Const Kind)+ decode (TString "Sort") =+ return (Const Sort)+ decode (TString "_") =+ empty+ decode (TList [ TString x, TInt n ]) =+ return (Var (V x (fromIntegral n)))+ decode (TList [ TString x, TInteger n ]) =+ return (Var (V x n))+ decode (TList (TInt 0 : f₁ : xs₁)) = do+ f₀ <- decode f₁+ xs₀ <- traverse decode xs₁+ return (foldl App f₀ xs₀)+ decode (TList [ TInt 1, _A₁, b₁ ]) = do+ _A₀ <- decode _A₁+ b₀ <- decode b₁+ return (Lam "_" _A₀ b₀)+ decode (TList [ TInt 1, TString x, _A₁, b₁ ]) = do+ _A₀ <- decode _A₁+ b₀ <- decode b₁+ return (Lam x _A₀ b₀)+ decode (TList [ TInt 2, _A₁, _B₁ ]) = do+ _A₀ <- decode _A₁+ _B₀ <- decode _B₁+ return (Pi "_" _A₀ _B₀)+ decode (TList [ TInt 2, TString x, _A₁, _B₁ ]) = do+ _A₀ <- decode _A₁+ _B₀ <- decode _B₁+ return (Pi x _A₀ _B₀)+ decode (TList [ TInt 3, TInt n, l₁, r₁ ]) = do+ l₀ <- decode l₁+ r₀ <- decode r₁+ op <- case n of+ 0 -> return BoolOr+ 1 -> return BoolAnd+ 2 -> return BoolEQ+ 3 -> return BoolNE+ 4 -> return NaturalPlus+ 5 -> return NaturalTimes+ 6 -> return TextAppend+ 7 -> return ListAppend+ 8 -> return Combine+ 9 -> return Prefer+ 10 -> return CombineTypes+ 11 -> return ImportAlt+ _ -> empty+ return (op l₀ r₀)+ decode (TList [ TInt 4, _T₁ ]) = do+ _T₀ <- decode _T₁+ return (ListLit (Just _T₀) empty)+ decode (TList (TInt 4 : TNull : xs₁ )) = do+ xs₀ <- traverse decode xs₁+ return (ListLit Nothing (Data.Sequence.fromList xs₀))+ decode (TList [ TInt 5, _T₁ ]) = do+ _T₀ <- decode _T₁+ return (OptionalLit _T₀ Nothing)+ decode (TList [ TInt 5, TNull, t₁ ]) = do+ t₀ <- decode t₁+ return (Some t₀)+ decode (TList [ TInt 5, _T₁, t₁ ]) = do+ _T₀ <- decode _T₁+ t₀ <- decode t₁+ return (OptionalLit _T₀ (Just t₀))+ decode (TList [ TInt 6, t₁, u₁ ]) = do+ t₀ <- decode t₁+ u₀ <- decode u₁+ return (Merge t₀ u₀ Nothing)+ decode (TList [ TInt 6, t₁, u₁, _T₁ ]) = do+ t₀ <- decode t₁+ u₀ <- decode u₁+ _T₀ <- decode _T₁+ return (Merge t₀ u₀ (Just _T₀))+ decode (TList [ TInt 7, TMap xTs₁ ]) = do+ let process (TString x, _T₁) = do+ _T₀ <- decode _T₁++ return (x, _T₀)+ process _ =+ empty++ xTs₀ <- traverse process xTs₁++ return (Record (Dhall.Map.fromList xTs₀))+ decode (TList [ TInt 8, TMap xts₁ ]) = do+ let process (TString x, t₁) = do+ t₀ <- decode t₁++ return (x, t₀)+ process _ =+ empty++ xts₀ <- traverse process xts₁++ return (RecordLit (Dhall.Map.fromList xts₀))+ decode (TList [ TInt 9, t₁, TString x ]) = do+ t₀ <- decode t₁++ return (Field t₀ x)+ decode (TList (TInt 10 : t₁ : xs₁)) = do+ t₀ <- decode t₁++ let process (TString x) = return x+ process _ = empty++ xs₀ <- traverse process xs₁++ return (Project t₀ (Dhall.Set.fromList xs₀))+ decode (TList [ TInt 11, TMap xTs₁ ]) = do+ let process (TString x, _T₁) = do+ mT₀ <- case _T₁ of+ TNull -> return Nothing+ _ -> fmap Just (decode _T₁)++ return (x, mT₀)+ process _ =+ empty++ xTs₀ <- traverse process xTs₁++ return (Union (Dhall.Map.fromList xTs₀))+ decode (TList [ TInt 12, TString x, t₁, TMap yTs₁ ]) = do+ t₀ <- decode t₁++ let process (TString y, _T₁) = do+ _T₀ <- case _T₁ of+ TNull -> return Nothing+ _ -> fmap Just (decode _T₁)++ return (y, _T₀)+ process _ =+ empty++ yTs₀ <- traverse process yTs₁++ return (UnionLit x t₀ (Dhall.Map.fromList yTs₀))+ decode (TBool b) = do+ return (BoolLit b)+ decode (TList [ TInt 14, t₁, l₁, r₁ ]) = do+ t₀ <- decode t₁+ l₀ <- decode l₁+ r₀ <- decode r₁++ return (BoolIf t₀ l₀ r₀)+ decode (TList [ TInt 15, TInt n ]) = do+ return (NaturalLit (fromIntegral n))+ decode (TList [ TInt 15, TInteger n ]) = do+ return (NaturalLit (fromInteger n))+ decode (TList [ TInt 16, TInt n ]) = do+ return (IntegerLit (fromIntegral n))+ decode (TList [ TInt 16, TInteger n ]) = do+ return (IntegerLit n)+ decode (THalf n) = do+ return (DoubleLit (float2Double n))+ decode (TFloat n) = do+ return (DoubleLit (float2Double n))+ decode (TDouble n) = do+ return (DoubleLit n)+ decode (TList (TInt 18 : xs)) = do+ let process (TString x : y₁ : zs) = do+ y₀ <- decode y₁++ ~(xys, z) <- process zs++ return ((x, y₀) : xys, z)+ process [ TString z ] = do+ return ([], z)+ process _ = do+ empty++ (xys, z) <- process xs++ return (TextLit (Chunks xys z))+ decode e@(TList (TInt 24 : _)) = fmap Embed (decode e)+ decode (TList (TInt 25 : xs)) = do+ let process (TString x : _A₁ : a₁ : ls₁) = do+ mA₀ <- case _A₁ of+ TNull -> return Nothing+ _ -> fmap Just (decode _A₁)++ a₀ <- decode a₁++ let binding = Binding x mA₀ a₀++ case ls₁ of+ [ b₁ ] -> do+ b₀ <- decode b₁++ return (Let (binding :| []) b₀)+ _ -> do+ Let (l₀ :| ls₀) b₀ <- process ls₁++ return (Let (binding :| (l₀ : ls₀)) b₀)+ process _ = do+ empty++ process xs+ decode (TList [ TInt 26, t₁, _T₁ ]) = do+ t₀ <- decode t₁+ _T₀ <- decode _T₁+ return (Annot t₀ _T₀)+ decode _ =+ empty++instance FromTerm Import where+ decode (TList (TInt 24 : h : TInt mode : TInt n : xs)) = do+ hash <- case h of+ TNull -> do+ return Nothing++ TList [ TString "sha256", TString base16Text ] -> do+ let base16Bytes = Data.Text.Encoding.encodeUtf8 base16Text+ digestBytes <- case Data.ByteArray.Encoding.convertFromBase Base16 base16Bytes of+ Left _ -> empty+ Right digestBytes -> return (digestBytes :: Data.ByteString.ByteString)++ digest <- Crypto.Hash.digestFromByteString digestBytes+ return (Just digest)++ _ -> do+ empty++ importMode <- case mode of+ 0 -> return Code+ 1 -> return RawText+ _ -> empty++ let remote scheme = do+ let process [ TString file, q ] = do+ query <- case q of+ TNull -> return Nothing+ TString x -> return (Just x)+ _ -> empty+ return ([], file, query)+ process (TString path : ys) = do+ (paths, file, query) <- process ys+ return (path : paths, file, query)+ process _ = do+ empty++ (headers, authority, paths, file, query) <- case xs of+ headers₀ : TString authority : ys -> do+ headers₁ <- case headers₀ of+ TNull -> return Nothing+ _ -> do+ Embed (Import { importHashed = headers }) <- decode headers₀+ return (Just headers)+ (paths, file, query) <- process ys+ return (headers₁, authority, paths, file, query)+ _ -> do+ empty++ let components = reverse paths+ let directory = Directory {..}+ let path = File {..}++ return (Remote (URL {..}))++ let local prefix = do+ let process [ TString file ] = do+ return ([], file)+ process (TString path : ys) = do+ (paths, file) <- process ys+ return (path : paths, file)+ process _ =+ empty++ (paths, file) <- process xs++ let components = reverse paths+ let directory = Directory {..}++ return (Local prefix (File {..}))++ let env = do+ case xs of+ [ TString x ] -> return (Env x)+ _ -> empty++ let missing = return Missing++ importType <- case n of+ 0 -> remote HTTP+ 1 -> remote HTTPS+ 2 -> local Absolute+ 3 -> local Here+ 4 -> local Parent+ 5 -> local Home+ 6 -> env+ 7 -> missing+ _ -> empty++ let importHashed = ImportHashed {..}++ return (Import {..})++ decode _ = empty++-- | Encode a Dhall expression as a CBOR `Term`+encodeExpression :: Expr s Import -> Term+encodeExpression = encode++-- | Decode a Dhall expression from a CBOR `Term`+decodeExpression :: Term -> Either DecodingFailure (Expr s Import)+decodeExpression term =+ case decodeWithoutVersion <|> decodeWithVersion of+ Just expression -> Right expression+ Nothing -> Left (CBORIsNotDhall term)+ where+ -- This is the behavior specified by the standard+ decodeWithoutVersion = decode term++ -- For backwards compatibility with older expressions that have a version+ -- tag to ease the migration+ decodeWithVersion = do+ TList [ TString _, taggedTerm ] <- return term+ decode taggedTerm data DecodingFailure = CBORIsNotDhall Term deriving (Eq)
@@ -0,0 +1,10 @@+module Dhall.Binary where++import Codec.CBOR.Term (Term)++import {-# SOURCE #-} Dhall.Core++class ToTerm a where+ encode :: a -> Term++instance ToTerm a => ToTerm (Expr s a)
@@ -26,7 +26,6 @@ , ImportMode(..) , ImportType(..) , URL(..)- , Path , Scheme(..) , Var(..) , Binding(..)@@ -34,7 +33,7 @@ , Expr(..) -- * Normalization- , alphaNormalize+ , Dhall.Core.alphaNormalize , normalize , normalizeWith , normalizeWithM@@ -58,6 +57,7 @@ , escapeText , subExpressions , pathCharacter+ , throws ) where #if MIN_VERSION_base(4,8,0)@@ -65,6 +65,8 @@ import Control.Applicative (Applicative(..), (<$>)) #endif import Control.Applicative (empty)+import Control.Exception (Exception)+import Control.Monad.IO.Class (MonadIO(..)) import Crypto.Hash (SHA256) import Data.Bifunctor (Bifunctor(..)) import Data.Data (Data)@@ -85,17 +87,21 @@ import Numeric.Natural (Natural) import Prelude hiding (succ) +import qualified Control.Exception import qualified Control.Monad import qualified Crypto.Hash import qualified Data.Char+import {-# SOURCE #-} qualified Dhall.Eval import qualified Data.HashSet import qualified Data.Sequence import qualified Data.Text import qualified Data.Text.Prettyprint.Doc as Pretty import qualified Dhall.Map import qualified Dhall.Set+import qualified Network.URI.Encode as URI.Encode import qualified Text.Printf + {-| Constants for a pure type system The axioms are:@@ -178,10 +184,36 @@ , authority :: Text , path :: File , query :: Maybe Text- , fragment :: Maybe Text , headers :: Maybe ImportHashed } deriving (Eq, Generic, Ord, Show) +instance Pretty URL where+ pretty (URL {..}) =+ schemeDoc+ <> "://"+ <> Pretty.pretty authority+ <> pathDoc+ <> queryDoc+ <> foldMap prettyHeaders headers+ where+ prettyHeaders h = " using " <> Pretty.pretty h++ File {..} = path++ Directory {..} = directory++ pathDoc =+ foldMap prettyURIComponent (reverse components)+ <> prettyURIComponent file++ schemeDoc = case scheme of+ HTTP -> "http"+ HTTPS -> "https"++ queryDoc = case query of+ Nothing -> ""+ Just q -> "?" <> Pretty.pretty q+ -- | The type of import (i.e. local vs. remote vs. environment) data ImportType = Local FilePrefix File@@ -222,28 +254,7 @@ pretty (Local prefix file) = Pretty.pretty prefix <> Pretty.pretty file - pretty (Remote (URL {..})) =- schemeDoc- <> "://"- <> Pretty.pretty authority- <> Pretty.pretty path- <> queryDoc- <> fragmentDoc- <> foldMap prettyHeaders headers- where- prettyHeaders h = " using " <> Pretty.pretty h-- schemeDoc = case scheme of- HTTP -> "http"- HTTPS -> "https"-- queryDoc = case query of- Nothing -> ""- Just q -> "?" <> Pretty.pretty q-- fragmentDoc = case fragment of- Nothing -> ""- Just f -> "#" <> Pretty.pretty f+ pretty (Remote url) = Pretty.pretty url pretty (Env env) = "env:" <> Pretty.pretty env @@ -286,11 +297,6 @@ RawText -> " as Text" Code -> "" --- | Type synonym for `Import`, provided for backwards compatibility-type Path = Import--{-# DEPRECATED Path "Use Dhall.Core.Import instead" #-}- {-| Label for a bound variable The `Text` field is the variable's name (i.e. \"@x@\").@@ -447,10 +453,10 @@ | Record (Map Text (Expr s a)) -- | > RecordLit [(k1, v1), (k2, v2)] ~ { k1 = v1, k2 = v2 } | RecordLit (Map Text (Expr s a))- -- | > Union [(k1, t1), (k2, t2)] ~ < k1 : t1 | k2 : t2 >- | Union (Map Text (Expr s a))- -- | > UnionLit k v [(k1, t1), (k2, t2)] ~ < k = v | k1 : t1 | k2 : t2 >- | UnionLit Text (Expr s a) (Map Text (Expr s a))+ -- | > Union [(k1, Just t1), (k2, Nothing)] ~ < k1 : t1 | k2 >+ | Union (Map Text (Maybe (Expr s a)))+ -- | > UnionLit k v [(k1, Just t1), (k2, Nothing)] ~ < k = v | k1 : t1 | k2 >+ | UnionLit Text (Expr s a) (Map Text (Maybe (Expr s a))) -- | > Combine x y ~ x ∧ y | Combine (Expr s a) (Expr s a) -- | > CombineTypes x y ~ x ⩓ y@@ -531,8 +537,8 @@ fmap _ OptionalBuild = OptionalBuild fmap f (Record r) = Record (fmap (fmap f) r) fmap f (RecordLit r) = RecordLit (fmap (fmap f) r)- fmap f (Union u) = Union (fmap (fmap f) u)- fmap f (UnionLit v e u) = UnionLit v (fmap f e) (fmap (fmap f) u)+ fmap f (Union u) = Union (fmap (fmap (fmap f)) u)+ fmap f (UnionLit v e u) = UnionLit v (fmap f e) (fmap (fmap (fmap f)) u) fmap f (Combine e1 e2) = Combine (fmap f e1) (fmap f e2) fmap f (CombineTypes e1 e2) = CombineTypes (fmap f e1) (fmap f e2) fmap f (Prefer e1 e2) = Prefer (fmap f e1) (fmap f e2)@@ -608,8 +614,8 @@ OptionalBuild >>= _ = OptionalBuild Record a >>= k = Record (fmap (>>= k) a) RecordLit a >>= k = RecordLit (fmap (>>= k) a)- Union a >>= k = Union (fmap (>>= k) a)- UnionLit a b c >>= k = UnionLit a (b >>= k) (fmap (>>= k) c)+ Union a >>= k = Union (fmap (fmap (>>= k)) a)+ UnionLit a b c >>= k = UnionLit a (b >>= k) (fmap (fmap (>>= k)) c) Combine a b >>= k = Combine (a >>= k) (b >>= k) CombineTypes a b >>= k = CombineTypes (a >>= k) (b >>= k) Prefer a b >>= k = Prefer (a >>= k) (b >>= k)@@ -675,8 +681,8 @@ first _ OptionalBuild = OptionalBuild first k (Record a ) = Record (fmap (first k) a) first k (RecordLit a ) = RecordLit (fmap (first k) a)- first k (Union a ) = Union (fmap (first k) a)- first k (UnionLit a b c ) = UnionLit a (first k b) (fmap (first k) c)+ first k (Union a ) = Union (fmap (fmap (first k)) a)+ first k (UnionLit a b c ) = UnionLit a (first k b) (fmap (fmap (first k)) c) first k (Combine a b ) = Combine (first k a) (first k b) first k (CombineTypes a b ) = CombineTypes (first k a) (first k b) first k (Prefer a b ) = Prefer (first k a) (first k b)@@ -934,11 +940,11 @@ a' = fmap (shift d v) a shift d v (Union a) = Union a' where- a' = fmap (shift d v) a+ a' = fmap (fmap (shift d v)) a shift d v (UnionLit a b c) = UnionLit a b' c' where- b' = shift d v b- c' = fmap (shift d v) c+ b' = shift d v b+ c' = fmap (fmap (shift d v)) c shift d v (Combine a b) = Combine a' b' where a' = shift d v a@@ -1104,10 +1110,19 @@ subst _ _ None = None subst _ _ OptionalFold = OptionalFold subst _ _ OptionalBuild = OptionalBuild-subst x e (Record kts) = Record (fmap (subst x e) kts)-subst x e (RecordLit kvs) = RecordLit (fmap (subst x e) kvs)-subst x e (Union kts) = Union (fmap (subst x e) kts)-subst x e (UnionLit a b kts) = UnionLit a (subst x e b) (fmap (subst x e) kts)+subst x e (Record kts) = Record kts'+ where+ kts' = fmap (subst x e) kts+subst x e (RecordLit kvs) = RecordLit kvs'+ where+ kvs' = fmap (subst x e) kvs+subst x e (Union kts) = Union kts'+ where+ kts' = fmap (fmap (subst x e)) kts+subst x e (UnionLit a b kts) = UnionLit a b' kts'+ where+ b' = subst x e b+ kts' = fmap (fmap (subst x e)) kts subst x e (Combine a b) = Combine a' b' where a' = subst x e a@@ -1155,293 +1170,7 @@ -} alphaNormalize :: Expr s a -> Expr s a-alphaNormalize (Const c) =- Const c-alphaNormalize (Var v) =- Var v-alphaNormalize (Lam "_" _A₀ b₀) =- Lam "_" _A₁ b₁- where- _A₁ = alphaNormalize _A₀- b₁ = alphaNormalize b₀-alphaNormalize (Lam x _A₀ b₀) =- Lam "_" _A₁ b₄- where- _A₁ = alphaNormalize _A₀-- b₁ = shift 1 (V "_" 0) b₀- b₂ = subst (V x 0) (Var (V "_" 0)) b₁- b₃ = shift (-1) (V x 0) b₂- b₄ = alphaNormalize b₃-alphaNormalize (Pi "_" _A₀ _B₀) =- Pi "_" _A₁ _B₁- where- _A₁ = alphaNormalize _A₀- _B₁ = alphaNormalize _B₀-alphaNormalize (Pi x _A₀ _B₀) =- Pi "_" _A₁ _B₄- where- _A₁ = alphaNormalize _A₀-- _B₁ = shift 1 (V "_" 0) _B₀- _B₂ = subst (V x 0) (Var (V "_" 0)) _B₁- _B₃ = shift (-1) (V x 0) _B₂- _B₄ = alphaNormalize _B₃-alphaNormalize (App f₀ a₀) =- App f₁ a₁- where- f₁ = alphaNormalize f₀-- a₁ = alphaNormalize a₀-alphaNormalize (Let (Binding "_" mA₀ a₀ :| []) b₀) =- Let (Binding "_" mA₁ a₁ :| []) b₁- where- mA₁ = fmap alphaNormalize mA₀- a₁ = alphaNormalize a₀-- b₁ = alphaNormalize b₀-alphaNormalize (Let (Binding "_" mA₀ a₀ :| (l₀ : ls₀)) b₀) =- case alphaNormalize (Let (l₀ :| ls₀) b₀) of- Let (l₁ :| ls₁) b₁ -> Let (Binding "_" mA₁ a₁ :| (l₁ : ls₁)) b₁- e -> Let (Binding "_" mA₁ a₁ :| [] ) e- where- mA₁ = fmap alphaNormalize mA₀- a₁ = alphaNormalize a₀-alphaNormalize (Let (Binding x mA₀ a₀ :| []) b₀) =- Let (Binding "_" mA₁ a₁ :| []) b₄- where- mA₁ = fmap alphaNormalize mA₀- a₁ = alphaNormalize a₀-- b₁ = shift 1 (V "_" 0) b₀- b₂ = subst (V x 0) (Var (V "_" 0)) b₁- b₃ = shift (-1) (V x 0) b₂- b₄ = alphaNormalize b₃-alphaNormalize (Let (Binding x mA₀ a₀ :| (l₀ : ls₀)) b₀) =- case alphaNormalize (Let (l₀ :| ls₀) b₃) of- Let (l₁ :| ls₁) b₄ -> Let (Binding "_" mA₁ a₁ :| (l₁ : ls₁)) b₄- e -> Let (Binding "_" mA₁ a₁ :| [] ) e- where- mA₁ = fmap alphaNormalize mA₀- a₁ = alphaNormalize a₀-- b₁ = shift 1 (V "_" 0) b₀- b₂ = subst (V x 0) (Var (V "_" 0)) b₁- b₃ = shift (-1) (V x 0) b₂-alphaNormalize (Annot t₀ _T₀) =- Annot t₁ _T₁- where- t₁ = alphaNormalize t₀-- _T₁ = alphaNormalize _T₀-alphaNormalize Bool =- Bool-alphaNormalize (BoolLit b) =- BoolLit b-alphaNormalize (BoolAnd l₀ r₀) =- BoolAnd l₁ r₁- where- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize (BoolOr l₀ r₀) =- BoolOr l₁ r₁- where- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize (BoolEQ l₀ r₀) =- BoolEQ l₁ r₁- where- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize (BoolNE l₀ r₀) =- BoolNE l₁ r₁- where- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize (BoolIf t₀ l₀ r₀) =- BoolIf t₁ l₁ r₁- where- t₁ = alphaNormalize t₀-- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize Natural =- Natural-alphaNormalize (NaturalLit n) =- NaturalLit n-alphaNormalize NaturalFold =- NaturalFold-alphaNormalize NaturalBuild =- NaturalBuild-alphaNormalize NaturalIsZero =- NaturalIsZero-alphaNormalize NaturalEven =- NaturalEven-alphaNormalize NaturalOdd =- NaturalOdd-alphaNormalize NaturalToInteger =- NaturalToInteger-alphaNormalize NaturalShow =- NaturalShow-alphaNormalize (NaturalPlus l₀ r₀) =- NaturalPlus l₁ r₁- where- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize (NaturalTimes l₀ r₀) =- NaturalTimes l₁ r₁- where- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize Integer =- Integer-alphaNormalize (IntegerLit n) =- IntegerLit n-alphaNormalize IntegerShow =- IntegerShow-alphaNormalize IntegerToDouble =- IntegerToDouble-alphaNormalize Double =- Double-alphaNormalize (DoubleLit n) =- DoubleLit n-alphaNormalize DoubleShow =- DoubleShow-alphaNormalize Text =- Text-alphaNormalize (TextLit (Chunks xys₀ z)) =- TextLit (Chunks xys₁ z)- where- xys₁ = do- (x, y₀) <- xys₀- let y₁ = alphaNormalize y₀- return (x, y₁)-alphaNormalize (TextAppend l₀ r₀) =- TextAppend l₁ r₁- where- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize TextShow =- TextShow-alphaNormalize List =- List-alphaNormalize (ListLit (Just _T₀) ts₀) =- ListLit (Just _T₁) ts₁- where- _T₁ = alphaNormalize _T₀-- ts₁ = fmap alphaNormalize ts₀-alphaNormalize (ListLit Nothing ts₀) =- ListLit Nothing ts₁- where- ts₁ = fmap alphaNormalize ts₀-alphaNormalize (ListAppend l₀ r₀) =- ListAppend l₁ r₁- where- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize ListBuild =- ListBuild-alphaNormalize ListFold =- ListFold-alphaNormalize ListLength =- ListLength-alphaNormalize ListHead =- ListHead-alphaNormalize ListLast =- ListLast-alphaNormalize ListIndexed =- ListIndexed-alphaNormalize ListReverse =- ListReverse-alphaNormalize Optional =- Optional-alphaNormalize (OptionalLit _T₀ ts₀) =- OptionalLit _T₁ ts₁- where- _T₁ = alphaNormalize _T₀-- ts₁ = fmap alphaNormalize ts₀-alphaNormalize (Some a₀) = Some a₁- where- a₁ = alphaNormalize a₀-alphaNormalize None = None-alphaNormalize OptionalFold =- OptionalFold-alphaNormalize OptionalBuild =- OptionalBuild-alphaNormalize (Record kts₀) =- Record kts₁- where- kts₁ = fmap alphaNormalize kts₀-alphaNormalize (RecordLit kvs₀) =- RecordLit kvs₁- where- kvs₁ = fmap alphaNormalize kvs₀-alphaNormalize (Union kts₀) =- Union kts₁- where- kts₁ = fmap alphaNormalize kts₀-alphaNormalize (UnionLit k v₀ kts₀) =- UnionLit k v₁ kts₁- where- v₁ = alphaNormalize v₀-- kts₁ = fmap alphaNormalize kts₀-alphaNormalize (Combine l₀ r₀) =- Combine l₁ r₁- where- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize (CombineTypes l₀ r₀) =- CombineTypes l₁ r₁- where- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize (Prefer l₀ r₀) =- Prefer l₁ r₁- where- l₁ = alphaNormalize l₀-- r₁ = alphaNormalize r₀-alphaNormalize (Merge t₀ u₀ _T₀) =- Merge t₁ u₁ _T₁- where- t₁ = alphaNormalize t₀-- u₁ = alphaNormalize u₀-- _T₁ = fmap alphaNormalize _T₀-alphaNormalize (Field e₀ a) =- Field e₁ a- where- e₁ = alphaNormalize e₀-alphaNormalize (Project e₀ a) =- Project e₁ a- where- e₁ = alphaNormalize e₀-alphaNormalize (Note s e₀) =- Note s e₁- where- e₁ = alphaNormalize e₀-alphaNormalize (ImportAlt l₀ r₀) =- ImportAlt l₁ r₁- where- l₁ = alphaNormalize l₀- r₁ = alphaNormalize r₀-alphaNormalize (Embed a) =- Embed a+alphaNormalize = Dhall.Eval.alphaNormalize {-| Reduce an expression to its normal form, performing beta reduction @@ -1452,9 +1181,11 @@ However, `normalize` will not fail if the expression is ill-typed and will leave ill-typed sub-expressions unevaluated. -}+ normalize :: Eq a => Expr s a -> Expr t a-normalize = normalizeWith (const (pure Nothing))+normalize = Dhall.Eval.nfEmpty + {-| This function is used to determine whether folds like @Natural/fold@ or @List/fold@ should be lazy or strict in their accumulator based on the type of the accumulator@@ -1474,7 +1205,7 @@ boundedType (App List _) = False boundedType (App Optional t) = boundedType t boundedType (Record kvs) = all boundedType kvs-boundedType (Union kvs) = all boundedType kvs+boundedType (Union kvs) = all (all boundedType) kvs boundedType _ = False -- | Remove all `Note` constructors from an `Expr` (i.e. de-`Note`)@@ -1536,8 +1267,8 @@ denote OptionalBuild = OptionalBuild denote (Record a ) = Record (fmap denote a) denote (RecordLit a ) = RecordLit (fmap denote a)-denote (Union a ) = Union (fmap denote a)-denote (UnionLit a b c ) = UnionLit a (denote b) (fmap denote c)+denote (Union a ) = Union (fmap (fmap denote) a)+denote (UnionLit a b c ) = UnionLit a (denote b) (fmap (fmap denote) c) denote (Combine a b ) = Combine (denote a) (denote b) denote (CombineTypes a b ) = CombineTypes (denote a) (denote b) denote (Prefer a b ) = Prefer (denote a) (denote b)@@ -1562,10 +1293,12 @@ with those functions is not total either. -}-normalizeWith :: Eq a => Normalizer a -> Expr s a -> Expr t a-normalizeWith ctx = runIdentity . normalizeWithM ctx+normalizeWith :: Eq a => Maybe (ReifiedNormalizer a) -> Expr s a -> Expr t a+normalizeWith (Just ctx) t = runIdentity (normalizeWithM (getReifiedNormalizer ctx) t)+normalizeWith _ t = Dhall.Eval.nfEmpty t -normalizeWithM :: (Eq a, Monad m) => NormalizerM m a -> Expr s a -> m (Expr t a)+normalizeWithM+ :: (Monad m, Eq a) => NormalizerM m a -> Expr s a -> m (Expr t a) normalizeWithM ctx e0 = loop (denote e0) where loop e = case e of@@ -1818,15 +1551,7 @@ case y' of TextLit c -> pure [Chunks [] x, c] _ -> pure [Chunks [(x, y')] mempty]- TextAppend x y -> decide <$> loop x <*> loop y- where- isEmpty (Chunks [] "") = True- isEmpty _ = False-- decide (TextLit m) r | isEmpty m = r- decide l (TextLit n) | isEmpty n = l- decide (TextLit m) (TextLit n) = TextLit (m <> n)- decide l r = TextAppend l r+ TextAppend x y -> loop (TextLit (Chunks [("", x), ("", y)] "")) TextShow -> pure TextShow List -> pure List ListLit t es@@ -1865,11 +1590,11 @@ kvs' = traverse loop kvs Union kts -> Union . Dhall.Map.sort <$> kts' where- kts' = traverse loop kts+ kts' = traverse (traverse loop) kts UnionLit k v kvs -> UnionLit k <$> v' <*> (Dhall.Map.sort <$> kvs') where- v' = loop v- kvs' = traverse loop kvs+ v' = loop v+ kvs' = traverse (traverse loop) kvs Combine x y -> decide <$> loop x <*> loop y where decide (RecordLit m) r | Data.Foldable.null m =@@ -1910,6 +1635,22 @@ case Dhall.Map.lookup kY kvsX of Just vX -> loop (App vX vY) Nothing -> Merge x' y' <$> t'+ Field (Union ktsY) kY ->+ case Dhall.Map.lookup kY ktsY of+ Just Nothing ->+ case Dhall.Map.lookup kY kvsX of+ Just vX -> return vX+ Nothing -> Merge x' y' <$> t'+ _ ->+ Merge x' y' <$> t'+ App (Field (Union ktsY) kY) vY ->+ case Dhall.Map.lookup kY ktsY of+ Just (Just _) ->+ case Dhall.Map.lookup kY kvsX of+ Just vX -> loop (App vX vY)+ Nothing -> Merge x' y' <$> t'+ _ ->+ Merge x' y' <$> t' _ -> Merge x' y' <$> t' _ -> Merge x' y' <$> t' where@@ -1921,13 +1662,6 @@ case Dhall.Map.lookup x kvs of Just v -> loop v Nothing -> Field <$> (RecordLit <$> traverse loop kvs) <*> pure x- Union kvs ->- case Dhall.Map.lookup x kvs of- Just t_ -> Lam x <$> t' <*> pure (UnionLit x (Var (V x 0)) rest)- where- t' = loop t_- rest = Dhall.Map.delete x kvs- Nothing -> Field <$> (Union <$> traverse loop kvs) <*> pure x _ -> pure (Field r' x) Project r xs -> do r' <- loop r@@ -1944,7 +1678,8 @@ adapt x = do v <- Dhall.Map.lookup x kvs return (x, v)- _ -> pure (Project r' xs)+ _ | null xs -> pure (RecordLit mempty)+ | otherwise -> pure (Project r' xs) Note _ e' -> loop e' ImportAlt l _r -> loop l Embed a -> pure (Embed a)@@ -1959,17 +1694,15 @@ f '\n' = "\\n" f '\r' = "\\r" f '\t' = "\\t"- f c | c <= '\x1F' = Data.Text.pack (Text.Printf.printf "\\u%04d" (Data.Char.ord c))+ f '\f' = "\\f"+ f c | c <= '\x1F' = Data.Text.pack (Text.Printf.printf "\\u%04x" (Data.Char.ord c)) | otherwise = Data.Text.singleton c {-| Returns `True` if two expressions are α-equivalent and β-equivalent and `False` otherwise -} judgmentallyEqual :: Eq a => Expr s a -> Expr t a -> Bool-judgmentallyEqual eL0 eR0 = alphaBetaNormalize eL0 == alphaBetaNormalize eR0- where- alphaBetaNormalize :: Eq a => Expr s a -> Expr () a- alphaBetaNormalize = alphaNormalize . normalize+judgmentallyEqual = Dhall.Eval.convEmpty -- | Use this to wrap you embedded functions (see `normalizeWith`) to make them -- polymorphic enough to be used.@@ -1979,7 +1712,7 @@ -- | A reified 'Normalizer', which can be stored in structures without -- running into impredicative polymorphism.-data ReifiedNormalizer a = ReifiedNormalizer+newtype ReifiedNormalizer a = ReifiedNormalizer { getReifiedNormalizer :: Normalizer a } -- | Check if an expression is in a normal form given a context of evaluation.@@ -1987,7 +1720,7 @@ -- -- It is much more efficient to use `isNormalized`. isNormalizedWith :: (Eq s, Eq a) => Normalizer a -> Expr s a -> Bool-isNormalizedWith ctx e = e == normalizeWith ctx e+isNormalizedWith ctx e = e == normalizeWith (Just (ReifiedNormalizer ctx)) e -- | Quickly check if an expression is in normal form isNormalized :: Eq a => Expr s a -> Bool@@ -2103,15 +1836,7 @@ check y = loop y && case y of TextLit _ -> False _ -> True- TextAppend x y -> loop x && loop y && decide x y- where- isEmpty (Chunks [] "") = True- isEmpty _ = False-- decide (TextLit m) _ | isEmpty m = False- decide _ (TextLit n) | isEmpty n = False- decide (TextLit _) (TextLit _) = False- decide _ _ = True+ TextAppend _ _ -> False TextShow -> True List -> True ListLit t es -> all loop t && all loop es@@ -2136,8 +1861,8 @@ OptionalBuild -> True Record kts -> Dhall.Map.isSorted kts && all loop kts RecordLit kvs -> Dhall.Map.isSorted kvs && all loop kvs- Union kts -> Dhall.Map.isSorted kts && all loop kts- UnionLit _ v kvs -> loop v && Dhall.Map.isSorted kvs && all loop kvs+ Union kts -> Dhall.Map.isSorted kts && all (all loop) kts+ UnionLit _ v kvs -> loop v && Dhall.Map.isSorted kvs && all (all loop) kvs Combine x y -> loop x && loop y && decide x y where decide (RecordLit m) _ | Data.Foldable.null m = False@@ -2183,7 +1908,7 @@ if all (flip Dhall.Map.member kvs) xs then False else True- _ -> True+ _ -> not (null xs) Note _ e' -> loop e' ImportAlt l _r -> loop l Embed _ -> True@@ -2341,8 +2066,9 @@ subExpressions _ OptionalBuild = pure OptionalBuild subExpressions f (Record a) = Record <$> traverse f a subExpressions f ( RecordLit a ) = RecordLit <$> traverse f a-subExpressions f (Union a) = Union <$> traverse f a-subExpressions f (UnionLit a b c) = UnionLit a <$> f b <*> traverse f c+subExpressions f (Union a) = Union <$> traverse (traverse f) a+subExpressions f (UnionLit a b c) =+ UnionLit a <$> f b <*> traverse (traverse f) c subExpressions f (Combine a b) = Combine <$> f a <*> f b subExpressions f (CombineTypes a b) = CombineTypes <$> f a <*> f b subExpressions f (Prefer a b) = Prefer <$> f a <*> f b@@ -2377,3 +2103,17 @@ "/" <> Pretty.pretty text | otherwise = "/\"" <> Pretty.pretty text <> "\""++prettyURIComponent :: Text -> Doc ann+prettyURIComponent text+ | Data.Text.all (\c -> pathCharacter c && URI.Encode.isAllowed c) text =+ "/" <> Pretty.pretty text+ | otherwise =+ "/\"" <> Pretty.pretty text <> "\""++{-| Convenience utility for converting `Either`-based exceptions to `IO`-based+ exceptions+-}+throws :: (Exception e, MonadIO io) => Either e a -> io a+throws (Left e) = liftIO (Control.Exception.throwIO e)+throws (Right r) = return r
@@ -5,3 +5,7 @@ data Var data Expr s a++data Import++denote :: Expr s a -> Expr t a
@@ -27,6 +27,7 @@ import Data.Text (Text) import Data.Text.Prettyprint.Doc (Doc, Pretty) import Dhall.Core (Binding(..), Chunks (..), Const(..), Expr(..), Var(..))+import Dhall.Binary (ToTerm) import Dhall.Map (Map) import Dhall.Set (Set) import Dhall.Pretty.Internal (Ann)@@ -153,7 +154,7 @@ rparen = token Internal.rparen -- | Render the difference between the normal form of two expressions-diffNormalized :: (Eq a, Pretty a) => Expr s a -> Expr s a -> Doc Ann+diffNormalized :: (Eq a, Pretty a, ToTerm a) => Expr s a -> Expr s a -> Doc Ann diffNormalized l0 r0 = Dhall.Diff.diff l1 r1 where l1 = Dhall.Core.alphaNormalize (Dhall.Core.normalize l0)@@ -255,7 +256,17 @@ -> Map Text (Expr s a) -> Map Text (Expr s a) -> [Diff]-diffKeyVals assign kvsL kvsR =+diffKeyVals assign = diffKeysWith assign diffVals+ where+ diffVals l r = assign <> " " <> diffExpression l r++diffKeysWith+ :: Diff+ -> (a -> a -> Diff)+ -> Map Text a+ -> Map Text a+ -> [Diff]+diffKeysWith assign diffVals kvsL kvsR = diffFieldNames <> diffFieldValues <> (if anyEqual then [ ignore ] else []) where ksL = Data.Set.fromList (Dhall.Map.keys kvsL)@@ -274,7 +285,7 @@ <> ignore ] - shared = Dhall.Map.intersectionWith diffExpression kvsL kvsR+ shared = Dhall.Map.intersectionWith diffVals kvsL kvsR diffFieldValues = filter (not . same) (Dhall.Map.foldMapWithKey adapt shared)@@ -405,8 +416,10 @@ diffUnion :: (Eq a, Pretty a)- => Map Text (Expr s a) -> Map Text (Expr s a) -> Diff-diffUnion kvsL kvsR = angled (diffKeyVals colon kvsL kvsR)+ => Map Text (Maybe (Expr s a)) -> Map Text (Maybe (Expr s a)) -> Diff+diffUnion kvsL kvsR = angled (diffKeysWith colon diffVals kvsL kvsR)+ where+ diffVals = diffMaybe (colon <> " ") diffExpression diffUnionLit :: (Eq a, Pretty a)@@ -414,8 +427,8 @@ -> Text -> Expr s a -> Expr s a- -> Map Text (Expr s a)- -> Map Text (Expr s a)+ -> Map Text (Maybe (Expr s a))+ -> Map Text (Maybe (Expr s a)) -> Diff diffUnionLit kL kR vL vR kvsL kvsR = langle@@ -424,8 +437,10 @@ <> equals <> " " <> format " " (diffExpression vL vR)- <> halfAngled (diffKeyVals equals kvsL kvsR)+ <> halfAngled (diffKeysWith colon diffVals kvsL kvsR) where+ diffVals = diffMaybe (colon <> " ") diffExpression+ halfAngled = enclosed (pipe <> " ") (pipe <> " ") rangle listSkeleton :: Diff
@@ -0,0 +1,932 @@+{-# LANGUAGE+ BangPatterns,+ CPP,+ LambdaCase,+ OverloadedStrings,+ PatternSynonyms,+ RankNTypes,+ ScopedTypeVariables,+ TupleSections,+ ViewPatterns+ #-}++{-# OPTIONS_GHC+ -O+ -fno-warn-name-shadowing+ -fno-warn-unused-matches+ #-}++{-|+Eval-apply environment machine with conversion checking and quoting to normal+forms. Fairly similar to GHCI's STG machine algorithmically, but much simpler,+with no known call optimization or environment trimming.++Potential optimizations without changing Expr:+ - In conversion checking, get non-shadowing variables not by linear+ Env-walking, but by keeping track of Env size, and generating names which+ are known to be illegal as source-level names (to rule out shadowing).+ - Use HashMap Text chunks for large let-definitions blocks. "Large" vs "Small"+ is fairly cheap to determine at evaluation time.++Potential optimizations with changing Expr:+ - Use Int in Var instead of Integer. Overflow is practically impossible.+ - Use actual full de Bruijn indices in Var instead of Text counting indices. Then, we'd+ switch to full de Bruijn levels in Val as well, and use proper constant time non-shadowing+ name generation.++-}++module Dhall.Eval (+ Env(..)+ , Names(..)+ , Closure(..)+ , VChunks(..)+ , Val(..)+ , Void+ , inst+ , eval+ , conv+ , convEmpty+ , quote+ , nf+ , nfEmpty+ , Dhall.Eval.alphaNormalize+ ) where++#if MIN_VERSION_base(4,8,0)+#else+import Control.Applicative (Applicative(..), (<$>))+#endif++import Data.Foldable (foldr', foldl', toList)+import Data.List.NonEmpty (NonEmpty(..), cons)+import Data.Semigroup (Semigroup(..))+import Data.Sequence (Seq)+import Data.Text (Text)++import Dhall.Core (+ Expr(..)+ , Binding(..)+ , Chunks(..)+ , Const(..)+ , Import+ , Var(..)+ , denote+ )++-- import Control.Exception (throw)+-- import Dhall.Import.Types (InternalError)+import Dhall.Map (Map)+import Dhall.Set (Set)+import GHC.Natural (Natural)+import Unsafe.Coerce (unsafeCoerce)++import qualified Data.Char+import qualified Data.List.NonEmpty+import qualified Data.Sequence+import qualified Data.Text+import qualified Dhall.Binary+import qualified Dhall.Map+import qualified Text.Printf++----------------------------------------------------------------------------------------------------++data Env a =+ Empty+ | Skip !(Env a) {-# unpack #-} !Text+ | Extend !(Env a) {-# unpack #-} !Text (Val a)++data Void++coeExprVoid :: Expr Void a -> Expr s a+coeExprVoid = unsafeCoerce+{-# inline coeExprVoid #-}++errorMsg :: String+errorMsg = unlines+ [ _ERROR <> ": Compiler bug "+ , " "+ , "An ill-typed expression was encountered during normalization. "+ , "Explanation: This error message means that there is a bug in the Dhall compiler."+ , "You didn't do anything wrong, but if you would like to see this problem fixed "+ , "then you should report the bug at: "+ , " "+ , "https://github.com/dhall-lang/dhall-haskell/issues "+ ]+ where+ _ERROR :: String+ _ERROR = "\ESC[1;31mError\ESC[0m"+++data Closure a = Cl !Text !(Env a) !(Expr Void a)+data VChunks a = VChunks ![(Text, Val a)] !Text++instance Semigroup (VChunks a) where+ VChunks xys z <> VChunks [] z' = VChunks xys (z <> z')+ VChunks xys z <> VChunks ((x', y'):xys') z' = VChunks (xys ++ (z <> x', y'):xys') z'++instance Monoid (VChunks a) where+ mempty = VChunks [] mempty++#if !(MIN_VERSION_base(4,11,0))+ mappend = (<>)+#endif++data HLamInfo a+ = Prim+ | Typed !Text (Val a)+ | NaturalFoldCl (Val a)+ | ListFoldCl (Val a)+ | OptionalFoldCl (Val a)++pattern VPrim :: (Val a -> Val a) -> Val a+pattern VPrim f = VHLam Prim f++data Val a+ = VConst !Const+ | VVar !Text !Int+ | VPrimVar+ | VApp !(Val a) !(Val a)++ | VLam (Val a) {-# unpack #-} !(Closure a)+ | VHLam !(HLamInfo a) !(Val a -> Val a)++ | VPi (Val a) {-# unpack #-} !(Closure a)+ | VHPi !Text (Val a) !(Val a -> Val a)++ | VBool+ | VBoolLit !Bool+ | VBoolAnd !(Val a) !(Val a)+ | VBoolOr !(Val a) !(Val a)+ | VBoolEQ !(Val a) !(Val a)+ | VBoolNE !(Val a) !(Val a)+ | VBoolIf !(Val a) !(Val a) !(Val a)++ | VNatural+ | VNaturalLit !Natural+ | VNaturalFold !(Val a) !(Val a) !(Val a) !(Val a)+ | VNaturalBuild !(Val a)+ | VNaturalIsZero !(Val a)+ | VNaturalEven !(Val a)+ | VNaturalOdd !(Val a)+ | VNaturalToInteger !(Val a)+ | VNaturalShow !(Val a)+ | VNaturalPlus !(Val a) !(Val a)+ | VNaturalTimes !(Val a) !(Val a)++ | VInteger+ | VIntegerLit !Integer+ | VIntegerShow !(Val a)+ | VIntegerToDouble !(Val a)++ | VDouble+ | VDoubleLit !Double+ | VDoubleShow !(Val a)++ | VText+ | VTextLit !(VChunks a)+ | VTextAppend !(Val a) !(Val a)+ | VTextShow !(Val a)++ | VList !(Val a)+ | VListLit !(Maybe (Val a)) !(Seq (Val a))+ | VListAppend !(Val a) !(Val a)+ | VListBuild (Val a) !(Val a)+ | VListFold (Val a) !(Val a) !(Val a) !(Val a) !(Val a)+ | VListLength (Val a) !(Val a)+ | VListHead (Val a) !(Val a)+ | VListLast (Val a) !(Val a)+ | VListIndexed (Val a) !(Val a)+ | VListReverse (Val a) !(Val a)++ | VOptional (Val a)+ | VSome (Val a)+ | VNone (Val a)+ | VOptionalFold (Val a) !(Val a) (Val a) !(Val a) !(Val a)+ | VOptionalBuild (Val a) !(Val a)+ | VRecord !(Map Text (Val a))+ | VRecordLit !(Map Text (Val a))+ | VUnion !(Map Text (Maybe (Val a)))+ | VUnionLit !Text !(Val a) !(Map Text (Maybe (Val a)))+ | VCombine !(Val a) !(Val a)+ | VCombineTypes !(Val a) !(Val a)+ | VPrefer !(Val a) !(Val a)+ | VMerge !(Val a) !(Val a) !(Maybe (Val a))+ | VField !(Val a) !Text+ | VInject !(Map Text (Maybe (Val a))) !Text !(Maybe (Val a))+ | VProject !(Val a) !(Set Text)+ | VEmbed a++vFun :: Val a -> Val a -> Val a+vFun a b = VHPi "_" a (\_ -> b)+{-# inline vFun #-}++-- Evaluation+----------------------------------------------------------------------------------------------------++textShow :: Text -> Text+textShow text = "\"" <> Data.Text.concatMap f text <> "\""+ where+ f '"' = "\\\""+ f '$' = "\\u0024"+ f '\\' = "\\\\"+ f '\b' = "\\b"+ f '\n' = "\\n"+ f '\r' = "\\r"+ f '\t' = "\\t"+ f '\f' = "\\f"+ f c | c <= '\x1F' = Data.Text.pack (Text.Printf.printf "\\u%04x" (Data.Char.ord c))+ | otherwise = Data.Text.singleton c++countName :: Text -> Env a -> Int+countName x = go (0 :: Int) where+ go !acc Empty = acc+ go acc (Skip env x' ) = go (if x == x' then acc + 1 else acc) env+ go acc (Extend env x' _) = go (if x == x' then acc + 1 else acc) env++inst :: Eq a => Closure a -> Val a -> Val a+inst (Cl x env t) !u = eval (Extend env x u) t+{-# inline inst #-}++-- Out-of-env variables have negative de Bruijn levels.+vVar :: Env a -> Var -> Val a+vVar env (V x (fromInteger -> i :: Int)) = go env i where+ go (Extend env x' v) i+ | x == x' = if i == 0 then v else go env (i - 1)+ | otherwise = go env i+ go (Skip env x') i+ | x == x' = if i == 0 then VVar x (countName x env) else go env (i - 1)+ | otherwise = go env i+ go Empty i = VVar x (0 - i - 1)++vApp :: Eq a => Val a -> Val a -> Val a+vApp !t !u = case t of+ VLam _ t -> inst t u+ VHLam _ t -> t u+ t -> VApp t u+{-# inline vApp #-}++vCombine :: Val a -> Val a -> Val a+vCombine t u = case (t, u) of+ (VRecordLit m, u) | null m -> u+ (t, VRecordLit m) | null m -> t+ (VRecordLit m, VRecordLit m') -> VRecordLit (Dhall.Map.sort (Dhall.Map.unionWith vCombine m m'))+ (t, u) -> VCombine t u++vCombineTypes :: Val a -> Val a -> Val a+vCombineTypes t u = case (t, u) of+ (VRecord m, u) | null m -> u+ (t, VRecord m) | null m -> t+ (VRecord m, VRecord m') -> VRecord (Dhall.Map.sort (Dhall.Map.unionWith vCombineTypes m m'))+ (t, u) -> VCombineTypes t u++vListAppend :: Val a -> Val a -> Val a+vListAppend t u = case (t, u) of+ (VListLit _ xs, u) | null xs -> u+ (t, VListLit _ ys) | null ys -> t+ (VListLit t xs, VListLit _ ys) -> VListLit t (xs <> ys)+ (t, u) -> VListAppend t u+{-# inline vListAppend #-}++vNaturalPlus :: Val a -> Val a -> Val a+vNaturalPlus t u = case (t, u) of+ (VNaturalLit 0, u ) -> u+ (t, VNaturalLit 0) -> t+ (VNaturalLit m, VNaturalLit n) -> VNaturalLit (m + n)+ (t, u ) -> VNaturalPlus t u+{-# inline vNaturalPlus #-}++eval :: forall a. Eq a => Env a -> Expr Void a -> Val a+eval !env t =+ let+ evalE :: Expr Void a -> Val a+ evalE = eval env+ {-# inline evalE #-}++ evalChunks :: Chunks Void a -> VChunks a+ evalChunks (Chunks xys z) =+ foldr' (\(x, t) vcs ->+ case evalE t of+ VTextLit vcs' -> VChunks [] x <> vcs' <> vcs+ t -> VChunks [(x, t)] mempty <> vcs)+ (VChunks [] z)+ xys+ {-# inline evalChunks #-}++ in case t of+ Const k -> VConst k+ Var v -> vVar env v+ Lam x a t -> VLam (evalE a) (Cl x env t)+ Pi x a b -> VPi (evalE a) (Cl x env b)+ App t u -> vApp (evalE t) (evalE u)+ Let (b :| bs) t -> go env (b:bs) where+ go !env [] = eval env t+ go env (b:bs) = go (Extend env (variable b)+ (eval env (value b))) bs+ Annot t _ -> evalE t++ Bool -> VBool+ BoolLit b -> VBoolLit b+ BoolAnd t u -> case (evalE t, evalE u) of+ (VBoolLit True, u) -> u+ (VBoolLit False, u) -> VBoolLit False+ (t, VBoolLit True) -> t+ (t, VBoolLit False) -> VBoolLit False+ (t, u) | conv env t u -> t+ (t, u) -> VBoolAnd t u+ BoolOr t u -> case (evalE t, evalE u) of+ (VBoolLit False, u) -> u+ (VBoolLit True, u) -> VBoolLit True+ (t, VBoolLit False) -> t+ (t, VBoolLit True) -> VBoolLit True+ (t, u) | conv env t u -> t+ (t, u) -> VBoolOr t u+ BoolEQ t u -> case (evalE t, evalE u) of+ (VBoolLit True, u) -> u+ (t, VBoolLit True) -> t+ (t, u) | conv env t u -> VBoolLit True+ (t, u) -> VBoolEQ t u+ BoolNE t u -> case (evalE t, evalE u) of+ (VBoolLit False, u) -> u+ (t, VBoolLit False) -> t+ (t, u) | conv env t u -> VBoolLit False+ (t, u) -> VBoolNE t u+ BoolIf b t f -> case (evalE b, evalE t, evalE f) of+ (VBoolLit True, t, f) -> t+ (VBoolLit False, t, f) -> f+ (b, VBoolLit True, VBoolLit False) -> b+ (b, t, f) | conv env t f -> t+ (b, t, f) -> VBoolIf b t f++ Natural -> VNatural+ NaturalLit n -> VNaturalLit n+ NaturalFold -> VPrim $ \case+ VNaturalLit n ->+ VHLam (Typed "natural" (VConst Type)) $ \natural ->+ VHLam (Typed "succ" (vFun natural natural)) $ \succ ->+ VHLam (Typed "zero" natural) $ \zero ->+ let go !acc 0 = acc+ go acc n = go (vApp succ acc) (n - 1)+ in go zero n+ n ->+ VHLam (NaturalFoldCl n) $ \natural -> VPrim $ \succ -> VPrim $ \zero ->+ VNaturalFold n natural succ zero+ NaturalBuild -> VPrim $ \case+ VHLam (NaturalFoldCl x) _ -> x+ VPrimVar -> VNaturalBuild VPrimVar+ t ->+ t `vApp` VNatural+ `vApp` VHLam (Typed "n" VNatural) (\n -> vNaturalPlus n (VNaturalLit 1))+ `vApp` VNaturalLit 0++ NaturalIsZero -> VPrim $ \case VNaturalLit n -> VBoolLit (n == 0)+ n -> VNaturalIsZero n+ NaturalEven -> VPrim $ \case VNaturalLit n -> VBoolLit (even n)+ n -> VNaturalEven n+ NaturalOdd -> VPrim $ \case VNaturalLit n -> VBoolLit (odd n)+ n -> VNaturalOdd n+ NaturalToInteger -> VPrim $ \case VNaturalLit n -> VIntegerLit (fromIntegral n)+ n -> VNaturalToInteger n+ NaturalShow -> VPrim $ \case VNaturalLit n -> VTextLit (VChunks [] (Data.Text.pack (show n)))+ n -> VNaturalShow n+ NaturalPlus t u -> vNaturalPlus (evalE t) (evalE u)+ NaturalTimes t u -> case (evalE t, evalE u) of+ (VNaturalLit 1, u ) -> u+ (t, VNaturalLit 1) -> t+ (VNaturalLit 0, u ) -> VNaturalLit 0+ (t, VNaturalLit 0) -> VNaturalLit 0+ (VNaturalLit m, VNaturalLit n) -> VNaturalLit (m * n)+ (t, u ) -> VNaturalTimes t u++ Integer -> VInteger+ IntegerLit n -> VIntegerLit n+ IntegerShow -> VPrim $ \case+ VIntegerLit n+ | 0 <= n -> VTextLit (VChunks [] (Data.Text.pack ('+':show n)))+ | otherwise -> VTextLit (VChunks [] (Data.Text.pack (show n)))+ n -> VIntegerShow n+ IntegerToDouble -> VPrim $ \case VIntegerLit n -> VDoubleLit (read (show n))+ -- `(read . show)` is used instead of `fromInteger`+ -- because `read` uses the correct rounding rule+ n -> VIntegerToDouble n++ Double -> VDouble+ DoubleLit n -> VDoubleLit n+ DoubleShow -> VPrim $ \case VDoubleLit n -> VTextLit (VChunks [] (Data.Text.pack (show n)))+ n -> VDoubleShow n++ Text -> VText+ TextLit cs -> case evalChunks cs of+ VChunks [("", t)] "" -> t+ vcs -> VTextLit vcs+ TextAppend t u -> evalE (TextLit (Chunks [("", t), ("", u)] ""))+ TextShow -> VPrim $ \case+ VTextLit (VChunks [] x) -> VTextLit (VChunks [] (textShow x))+ t -> VTextShow t++ List -> VPrim VList+ ListLit ma ts -> VListLit (evalE <$> ma) (evalE <$> ts)+ ListAppend t u -> vListAppend (evalE t) (evalE u)+ ListBuild -> VPrim $ \a -> VPrim $ \case+ VHLam (ListFoldCl x) _ -> x+ VPrimVar -> VListBuild a VPrimVar+ t ->+ t `vApp` VList a+ `vApp` VHLam (Typed "a" a) (\x ->+ VHLam (Typed "as" (VList a)) (\as ->+ vListAppend (VListLit Nothing (pure x)) as))+ `vApp` VListLit (Just a) mempty++ ListFold -> VPrim $ \a -> VPrim $ \case+ VListLit _ as ->+ VHLam (Typed "list" (VConst Type)) $ \list ->+ VHLam (Typed "cons" (vFun a $ vFun list list) ) $ \cons ->+ VHLam (Typed "nil" list) $ \nil ->+ foldr' (\x b -> cons `vApp` x `vApp` b) nil as+ as ->+ VHLam (ListFoldCl as) $ \t -> VPrim $ \c -> VPrim $ \n ->+ VListFold a as t c n++ ListLength -> VPrim $ \ a -> VPrim $ \case+ VListLit _ as -> VNaturalLit (fromIntegral (Data.Sequence.length as))+ as -> VListLength a as+ ListHead -> VPrim $ \ a -> VPrim $ \case+ VListLit _ as -> case Data.Sequence.viewl as of+ y Data.Sequence.:< _ -> VSome y+ _ -> VNone a+ as -> VListHead a as+ ListLast -> VPrim $ \ a -> VPrim $ \case+ VListLit _ as -> case Data.Sequence.viewr as of+ _ Data.Sequence.:> t -> VSome t+ _ -> VNone a+ as -> VListLast a as+ ListIndexed -> VPrim $ \ a -> VPrim $ \case+ VListLit _ as -> let+ a' = if null as then+ Just (VRecord (Dhall.Map.fromList+ [("index", VNatural), ("value", a)]))+ else+ Nothing+ as' = Data.Sequence.mapWithIndex+ (\i t -> VRecordLit+ (Dhall.Map.fromList [("index", VNaturalLit (fromIntegral i)),+ ("value", t)]))+ as+ in VListLit a' as'+ t -> VListIndexed a t+ ListReverse -> VPrim $ \ ~a -> VPrim $ \case+ VListLit t as | null as -> VListLit t (Data.Sequence.reverse as)+ VListLit t as -> VListLit Nothing (Data.Sequence.reverse as)+ t -> VListReverse a t++ Optional -> VPrim VOptional+ OptionalLit a mt -> maybe (VNone (evalE a)) (\t -> VSome (evalE t)) mt+ Some t -> VSome (evalE t)+ None -> VPrim $ \ ~a -> VNone a++ OptionalFold -> VPrim $ \ ~a -> VPrim $ \case+ VNone _ ->+ VHLam (Typed "optional" (VConst Type)) $ \optional ->+ VHLam (Typed "some" (vFun a optional)) $ \some ->+ VHLam (Typed "none" optional) $ \none ->+ none+ VSome t ->+ VHLam (Typed "optional" (VConst Type)) $ \optional ->+ VHLam (Typed "some" (vFun a optional)) $ \some ->+ VHLam (Typed "none" optional) $ \none ->+ some `vApp` t+ opt ->+ VHLam (OptionalFoldCl opt) $ \o ->+ VPrim $ \s ->+ VPrim $ \n ->+ VOptionalFold a opt o s n+ OptionalBuild -> VPrim $ \ ~a -> VPrim $ \case+ VHLam (OptionalFoldCl x) _ -> x+ VPrimVar -> VOptionalBuild a VPrimVar+ t -> t `vApp` VOptional a+ `vApp` VHLam (Typed "a" a) VSome+ `vApp` VNone a++ Record kts -> VRecord (Dhall.Map.sort (evalE <$> kts))+ RecordLit kts -> VRecordLit (Dhall.Map.sort (evalE <$> kts))+ Union kts -> VUnion (Dhall.Map.sort ((evalE <$>) <$> kts))+ UnionLit k v kts -> VUnionLit k (evalE v) (Dhall.Map.sort ((evalE <$>) <$> kts))+ Combine t u -> vCombine (evalE t) (evalE u)+ CombineTypes t u -> vCombineTypes (evalE t) (evalE u)+ Prefer t u -> case (evalE t, evalE u) of+ (VRecordLit m, u) | null m -> u+ (t, VRecordLit m) | null m -> t+ (VRecordLit m, VRecordLit m') ->+ VRecordLit (Dhall.Map.sort (Dhall.Map.union m' m))+ (t, u) -> VPrefer t u+ Merge x y ma -> case (evalE x, evalE y, evalE <$> ma) of+ (VRecordLit m, VUnionLit k v _, _)+ | Just f <- Dhall.Map.lookup k m -> f `vApp` v+ | otherwise -> error errorMsg+ (VRecordLit m, VInject _ k mt, _)+ | Just f <- Dhall.Map.lookup k m -> maybe f (vApp f) mt+ | otherwise -> error errorMsg+ (x, y, ma) -> VMerge x y ma+ Field t k -> case evalE t of+ VRecordLit m+ | Just v <- Dhall.Map.lookup k m -> v+ | otherwise -> error errorMsg+ VUnion m -> case Dhall.Map.lookup k m of+ Just (Just _) -> VPrim $ \ ~u -> VInject m k (Just u)+ Just Nothing -> VInject m k Nothing+ _ -> error errorMsg+ t -> VField t k+ Project t ks -> if null ks then+ VRecordLit mempty+ else case evalE t of+ VRecordLit kvs+ | Just s <- traverse (\k -> (k,) <$> Dhall.Map.lookup k kvs) (toList ks)+ -> VRecordLit (Dhall.Map.sort (Dhall.Map.fromList s))+ | otherwise -> error errorMsg+ t -> VProject t ks+ Note _ e -> evalE e+ ImportAlt t _ -> evalE t+ Embed a -> VEmbed a+++-- Conversion checking+--------------------------------------------------------------------------------++eqListBy :: (a -> a -> Bool) -> [a] -> [a] -> Bool+eqListBy f = go where+ go (x:xs) (y:ys) | f x y = go xs ys+ go [] [] = True+ go _ _ = False+{-# inline eqListBy #-}++eqMaybeBy :: (a -> a -> Bool) -> Maybe a -> Maybe a -> Bool+eqMaybeBy f = go where+ go (Just x) (Just y) = f x y+ go Nothing Nothing = True+ go _ _ = False+{-# inline eqMaybeBy #-}++conv :: forall a. Eq a => Env a -> Val a -> Val a -> Bool+conv !env t t' =+ let+ fresh :: Text -> (Text, Val a)+ fresh x = (x, VVar x (countName x env))+ {-# inline fresh #-}++ freshCl :: Closure a -> (Text, Val a, Closure a)+ freshCl cl@(Cl x _ _) = (x, snd (fresh x), cl)+ {-# inline freshCl #-}++ convChunks :: VChunks a -> VChunks a -> Bool+ convChunks (VChunks xys z) (VChunks xys' z') =+ eqListBy (\(x, y) (x', y') -> x == x' && conv env y y') xys xys' && z == z'+ {-# inline convChunks #-}++ convE :: Val a -> Val a -> Bool+ convE = conv env+ {-# inline convE #-}++ convSkip :: Text -> Val a -> Val a -> Bool+ convSkip x = conv (Skip env x)+ {-# inline convSkip #-}++ in case (t, t') of+ (VConst k, VConst k') -> k == k'+ (VVar x i, VVar x' i') -> x == x' && i == i'++ (VLam _ (freshCl -> (x, v, t)), VLam _ t' ) -> convSkip x (inst t v) (inst t' v)+ (VLam _ (freshCl -> (x, v, t)), VHLam _ t') -> convSkip x (inst t v) (t' v)+ (VLam _ (freshCl -> (x, v, t)), t' ) -> convSkip x (inst t v) (vApp t' v)+ (VHLam _ t, VLam _ (freshCl -> (x, v, t'))) -> convSkip x (t v) (inst t' v)+ (VHLam _ t, VHLam _ t' ) -> let (x, v) = fresh "x" in convSkip x (t v) (t' v)+ (VHLam _ t, t' ) -> let (x, v) = fresh "x" in convSkip x (t v) (vApp t' v)++ (t, VLam _ (freshCl -> (x, v, t'))) -> convSkip x (vApp t v) (inst t' v)+ (t, VHLam _ t' ) -> let (x, v) = fresh "x" in convSkip x (vApp t v) (t' v)++ (VApp t u, VApp t' u') -> convE t t' && convE u u'++ (VPi a b, VPi a' (freshCl -> (x, v, b'))) ->+ convE a a' && convSkip x (inst b v) (inst b' v)+ (VPi a b, VHPi (fresh -> (x, v)) a' b') ->+ convE a a' && convSkip x (inst b v) (b' v)+ (VHPi _ a b, VPi a' (freshCl -> (x, v, b'))) ->+ convE a a' && convSkip x (b v) (inst b' v)+ (VHPi _ a b, VHPi (fresh -> (x, v)) a' b') ->+ convE a a' && convSkip x (b v) (b' v)++ (VBool , VBool ) -> True+ (VBoolLit b , VBoolLit b' ) -> b == b'+ (VBoolAnd t u, VBoolAnd t' u' ) -> convE t t' && convE u u'+ (VBoolOr t u, VBoolOr t' u' ) -> convE t t' && convE u u'+ (VBoolEQ t u, VBoolEQ t' u' ) -> convE t t' && convE u u'+ (VBoolNE t u, VBoolNE t' u' ) -> convE t t' && convE u u'+ (VBoolIf t u v, VBoolIf t' u' v') -> convE t t' && convE u u' && convE v v'++ (VNatural, VNatural) -> True+ (VNaturalLit n, VNaturalLit n') -> n == n'+ (VNaturalFold t _ u v, VNaturalFold t' _ u' v') ->+ convE t t' && convE u u' && convE v v'++ (VNaturalBuild t , VNaturalBuild t') -> convE t t'+ (VNaturalIsZero t , VNaturalIsZero t') -> convE t t'+ (VNaturalEven t , VNaturalEven t') -> convE t t'+ (VNaturalOdd t , VNaturalOdd t') -> convE t t'+ (VNaturalToInteger t , VNaturalToInteger t') -> convE t t'+ (VNaturalShow t , VNaturalShow t') -> convE t t'+ (VNaturalPlus t u , VNaturalPlus t' u') -> convE t t' && convE u u'+ (VNaturalTimes t u , VNaturalTimes t' u') -> convE t t' && convE u u'++ (VInteger , VInteger) -> True+ (VIntegerLit t , VIntegerLit t') -> t == t'+ (VIntegerShow t , VIntegerShow t') -> convE t t'+ (VIntegerToDouble t , VIntegerToDouble t') -> convE t t'++ (VDouble , VDouble) -> True+ (VDoubleLit n , VDoubleLit n') -> Dhall.Binary.encode (DoubleLit n :: Expr Void Import) ==+ Dhall.Binary.encode (DoubleLit n' :: Expr Void Import)+ (VDoubleShow t , VDoubleShow t') -> convE t t'++ (VText, VText) -> True++ (VTextLit cs , VTextLit cs') -> convChunks cs cs'+ (VTextAppend t u , VTextAppend t' u') -> convE t t' && convE u u'+ (VTextShow t , VTextShow t') -> convE t t'++ (VList a , VList a' ) -> convE a a'+ (VListLit _ xs , VListLit _ xs') -> eqListBy convE (toList xs) (toList xs')++ (VListAppend t u , VListAppend t' u' ) -> convE t t' && convE u u'+ (VListBuild a t , VListBuild a' t' ) -> convE t t'+ (VListLength a t , VListLength a' t' ) -> convE a a' && convE t t'+ (VListHead _ t , VListHead _ t' ) -> convE t t'+ (VListLast _ t , VListLast _ t' ) -> convE t t'+ (VListIndexed _ t , VListIndexed _ t' ) -> convE t t'+ (VListReverse _ t , VListReverse _ t' ) -> convE t t'+ (VListFold a l _ t u , VListFold a' l' _ t' u' ) ->+ convE a a' && convE l l' && convE t t' && convE u u'++ (VOptional a , VOptional a' ) -> convE a a'+ (VSome t , VSome t' ) -> convE t t'+ (VNone _ , VNone _ ) -> True+ (VOptionalBuild _ t , VOptionalBuild _ t' ) -> convE t t'+ (VRecord m , VRecord m' ) -> eqListBy convE (toList m) (toList m')+ (VRecordLit m , VRecordLit m' ) -> eqListBy convE (toList m) (toList m')+ (VUnion m , VUnion m' ) -> eqListBy (eqMaybeBy convE) (toList m) (toList m')+ (VUnionLit k v m , VUnionLit k' v' m' ) -> k == k' && convE v v' &&+ eqListBy (eqMaybeBy convE) (toList m) (toList m')+ (VCombine t u , VCombine t' u' ) -> convE t t' && convE u u'+ (VCombineTypes t u , VCombineTypes t' u' ) -> convE t t' && convE u u'+ (VPrefer t u , VPrefer t' u' ) -> convE t t' && convE u u'+ (VMerge t u _ , VMerge t' u' _ ) -> convE t t' && convE u u'+ (VField t k , VField t' k' ) -> convE t t' && k == k'+ (VProject t ks , VProject t' ks' ) -> convE t t' && ks == ks'+ (VInject m k mt , VInject m' k' mt' ) -> eqListBy (eqMaybeBy convE) (toList m) (toList m')+ && k == k' && eqMaybeBy convE mt mt'+ (VEmbed a , VEmbed a' ) -> a == a'+ (VOptionalFold a t _ u v , VOptionalFold a' t' _ u' v' ) ->+ convE a a' && convE t t' && convE u u' && convE v v'++ (_, _) -> False++convEmpty :: Eq a => Expr s a -> Expr t a -> Bool+convEmpty (denote -> t) (denote -> u) = conv Empty (eval Empty t) (eval Empty u)++-- Quoting+----------------------------------------------------------------------------------------------------++data Names+ = NEmpty+ | NBind !Names {-# unpack #-} !Text+ deriving Show++envNames :: Env a -> Names+envNames Empty = NEmpty+envNames (Skip env x ) = NBind (envNames env) x+envNames (Extend env x _) = NBind (envNames env) x++countName' :: Text -> Names -> Int+countName' x = go 0 where+ go !acc NEmpty = acc+ go acc (NBind env x') = go (if x == x' then acc + 1 else acc) env++-- | Quote a value into beta-normal form.+quote :: forall a. Eq a => Names -> Val a -> Expr Void a+quote !env !t =+ let+ fresh :: Text -> (Text, Val a)+ fresh x = (x, VVar x (countName' x env))+ {-# inline fresh #-}++ freshCl :: Closure a -> (Text, Val a, Closure a)+ freshCl cl@(Cl x _ _) = (x, snd (fresh x), cl)+ {-# inline freshCl #-}++ qVar :: Text -> Int -> Expr Void a+ qVar !x !i = Var (V x (fromIntegral (countName' x env - i - 1)))+ {-# inline qVar #-}++ quoteE :: Val a -> Expr Void a+ quoteE = quote env+ {-# inline quoteE #-}++ quoteBind :: Text -> Val a -> Expr Void a+ quoteBind x = quote (NBind env x)+ {-# inline quoteBind #-}++ qApp :: Expr Void a -> Val a -> Expr Void a+ qApp t VPrimVar = t+ qApp t u = App t (quoteE u)+ {-# inline qApp #-}++ in case t of+ VConst k -> Const k+ VVar x i -> qVar x i+ VApp t u -> quoteE t `qApp` u+ VLam a (freshCl -> (x, v, t)) -> Lam x (quoteE a) (quoteBind x (inst t v))+ VHLam i t -> case i of+ Typed (fresh -> (x, v)) a -> Lam x (quoteE a) (quoteBind x (t v))+ Prim -> quote env (t VPrimVar)+ NaturalFoldCl{} -> quote env (t VPrimVar)+ ListFoldCl{} -> quote env (t VPrimVar)+ OptionalFoldCl{} -> quote env (t VPrimVar)++ VPi a (freshCl -> (x, v, b)) -> Pi x (quoteE a) (quoteBind x (inst b v))+ VHPi (fresh -> (x, v)) a b -> Pi x (quoteE a) (quoteBind x (b v))++ VBool -> Bool+ VBoolLit b -> BoolLit b+ VBoolAnd t u -> BoolAnd (quoteE t) (quoteE u)+ VBoolOr t u -> BoolOr (quoteE t) (quoteE u)+ VBoolEQ t u -> BoolEQ (quoteE t) (quoteE u)+ VBoolNE t u -> BoolNE (quoteE t) (quoteE u)+ VBoolIf t u v -> BoolIf (quoteE t) (quoteE u) (quoteE v)++ VNatural -> Natural+ VNaturalLit n -> NaturalLit n+ VNaturalFold a t u v -> NaturalFold `qApp` a `qApp` t `qApp` u `qApp` v+ VNaturalBuild t -> NaturalBuild `qApp` t+ VNaturalIsZero t -> NaturalIsZero `qApp` t+ VNaturalEven t -> NaturalEven `qApp` t+ VNaturalOdd t -> NaturalOdd `qApp` t+ VNaturalToInteger t -> NaturalToInteger `qApp` t+ VNaturalShow t -> NaturalShow `qApp` t+ VNaturalPlus t u -> NaturalPlus (quoteE t) (quoteE u)+ VNaturalTimes t u -> NaturalTimes (quoteE t) (quoteE u)++ VInteger -> Integer+ VIntegerLit n -> IntegerLit n+ VIntegerShow t -> IntegerShow `qApp` t+ VIntegerToDouble t -> IntegerToDouble `qApp` t++ VDouble -> Double+ VDoubleLit n -> DoubleLit n+ VDoubleShow t -> DoubleShow `qApp` t++ VText -> Text+ VTextLit (VChunks xys z) -> TextLit (Chunks ((quoteE <$>) <$> xys) z)+ VTextAppend t u -> TextAppend (quoteE t) (quoteE u)+ VTextShow t -> TextShow `qApp` t++ VList t -> List `qApp` t+ VListLit ma ts -> ListLit (quoteE <$> ma) (quoteE <$> ts)+ VListAppend t u -> ListAppend (quoteE t) (quoteE u)+ VListBuild a t -> ListBuild `qApp` a `qApp` t+ VListFold a l t u v -> ListFold `qApp` a `qApp` l `qApp` t `qApp` u `qApp` v+ VListLength a t -> ListLength `qApp` a `qApp` t+ VListHead a t -> ListHead `qApp` a `qApp` t+ VListLast a t -> ListLast `qApp` a `qApp` t+ VListIndexed a t -> ListIndexed `qApp` a `qApp` t+ VListReverse a t -> ListReverse `qApp` a `qApp` t++ VOptional a -> Optional `qApp` a+ VSome t -> Some (quoteE t)+ VNone t -> None `qApp` t+ VOptionalFold a o t u v -> OptionalFold `qApp` a `qApp` o `qApp` t `qApp` u `qApp` v+ VOptionalBuild a t -> OptionalBuild `qApp` a `qApp` t+ VRecord m -> Record (quoteE <$> m)+ VRecordLit m -> RecordLit (quoteE <$> m)+ VUnion m -> Union ((quoteE <$>) <$> m)+ VUnionLit k v m -> UnionLit k (quoteE v) ((quoteE <$>) <$> m)+ VCombine t u -> Combine (quoteE t) (quoteE u)+ VCombineTypes t u -> CombineTypes (quoteE t) (quoteE u)+ VPrefer t u -> Prefer (quoteE t) (quoteE u)+ VMerge t u ma -> Merge (quoteE t) (quoteE u) (quoteE <$> ma)+ VField t k -> Field (quoteE t) k+ VProject t ks -> Project (quoteE t) ks+ VInject m k Nothing -> Field (Union ((quoteE <$>) <$> m)) k+ VInject m k (Just t) -> Field (Union ((quoteE <$>) <$> m)) k `qApp` t+ VEmbed a -> Embed a+ VPrimVar -> error errorMsg++-- Normalization+----------------------------------------------------------------------------------------------------++-- | Normalize an expression in an environment of values. Any variable pointing out of+-- the environment is treated as opaque free variable.+nf :: Eq a => Env a -> Expr s a -> Expr t a+nf !env = coeExprVoid . quote (envNames env) . eval env . denote++-- | Normalize an expression in an empty environment.+nfEmpty :: Eq a => Expr s a -> Expr t a+nfEmpty = nf Empty++-- Alpha-renaming+--------------------------------------------------------------------------------++-- | Rename all binders to "_".+alphaNormalize :: Expr s a -> Expr s a+alphaNormalize = goEnv NEmpty where++ goVar :: Names -> Text -> Integer -> Expr s a+ goVar e topX topI = go 0 e topI where+ go !acc (NBind env x) !i+ | x == topX = if i == 0 then Var (V "_" acc) else go (acc + 1) env (i - 1)+ | otherwise = go (acc + 1) env i+ go acc NEmpty i = Var (V topX topI)++ goEnv :: Names -> Expr s a -> Expr s a+ goEnv !e t = let++ go = goEnv e+ goBind x = goEnv (NBind e x)+ goChunks (Chunks ts x) = Chunks ((go <$>) <$> ts) x++ in case t of+ Const k -> Const k+ Var (V x i) -> goVar e x i+ Lam x t u -> Lam "_" (go t) (goBind x u)+ Pi x a b -> Pi "_" (go a) (goBind x b)+ App t u -> App (go t) (go u)++ Let (b :| bs) u ->+ let Binding x a t = b++ nil = (NBind e x, Binding "_" (goEnv e <$> a) (goEnv e t) :| [])++ snoc (e, bs) (Binding x a t) =+ (NBind e x, cons (Binding "_" (goEnv e <$> a) (goEnv e t)) bs)++ (e', Data.List.NonEmpty.reverse -> bs') = foldl' snoc nil bs++ in Let bs' (goEnv e' u)++ Annot t u -> Annot (go t) (go u)+ Bool -> Bool+ BoolLit b -> BoolLit b+ BoolAnd t u -> BoolAnd (go t) (go u)+ BoolOr t u -> BoolOr (go t) (go u)+ BoolEQ t u -> BoolEQ (go t) (go u)+ BoolNE t u -> BoolNE (go t) (go u)+ BoolIf b t f -> BoolIf (go t) (go t) (go f)+ Natural -> Natural+ NaturalLit n -> NaturalLit n+ NaturalFold -> NaturalFold+ NaturalBuild -> NaturalBuild+ NaturalIsZero -> NaturalIsZero+ NaturalEven -> NaturalEven+ NaturalOdd -> NaturalOdd+ NaturalToInteger -> NaturalToInteger+ NaturalShow -> NaturalShow+ NaturalPlus t u -> NaturalPlus (go t) (go u)+ NaturalTimes t u -> NaturalTimes (go t) (go u)+ Integer -> Integer+ IntegerLit n -> IntegerLit n+ IntegerShow -> IntegerShow+ IntegerToDouble -> IntegerToDouble+ Double -> Double+ DoubleLit n -> DoubleLit n+ DoubleShow -> DoubleShow+ Text -> Text+ TextLit cs -> TextLit (goChunks cs)+ TextAppend t u -> TextAppend (go t) (go u)+ TextShow -> TextShow+ List -> List+ ListLit ma ts -> ListLit (go <$> ma) (go <$> ts)+ ListAppend t u -> ListAppend (go t) (go u)+ ListBuild -> ListBuild+ ListFold -> ListFold+ ListLength -> ListLength+ ListHead -> ListHead+ ListLast -> ListLast+ ListIndexed -> ListIndexed+ ListReverse -> ListReverse+ Optional -> Optional+ OptionalLit a mt -> OptionalLit (go a) (go <$> mt)+ Some t -> Some (go t)+ None -> None+ OptionalFold -> OptionalFold+ OptionalBuild -> OptionalBuild+ Record kts -> Record (go <$> kts)+ RecordLit kts -> RecordLit (go <$> kts)+ Union kts -> Union ((go <$>) <$> kts)+ UnionLit k v kts -> UnionLit k (go v) ((go <$>) <$> kts)+ Combine t u -> Combine (go t) (go u)+ CombineTypes t u -> CombineTypes (go t) (go u)+ Prefer t u -> Prefer (go t) (go u)+ Merge x y ma -> Merge (go x) (go y) (go <$> ma)+ Field t k -> Field (go t) k+ Project t ks -> Project (go t) ks+ Note s e -> Note s (go e)+ ImportAlt t u -> ImportAlt (go t) (go u)+ Embed a -> Embed a
@@ -0,0 +1,8 @@++module Dhall.Eval where++import {-# SOURCE #-} Dhall.Core++convEmpty :: Eq a => Expr s a -> Expr t a -> Bool+nfEmpty :: Eq a => Expr s a -> Expr t a+alphaNormalize :: Expr s a -> Expr s a
@@ -12,7 +12,6 @@ ) where import Control.Exception (Exception)-import Control.Monad.IO.Class (MonadIO(..)) import Dhall.Parser (exprAndHeaderFromText) import Dhall.Pretty (CharacterSet(..), annToAnsiStyle, layoutOpts) @@ -23,6 +22,7 @@ import qualified Data.Text.Prettyprint.Doc.Render.Text as Pretty.Text import qualified Control.Exception import qualified Data.Text.IO+import qualified Dhall.Core import qualified Dhall.Pretty import qualified System.Console.ANSI import qualified System.IO@@ -64,7 +64,7 @@ Just file -> do text <- Data.Text.IO.readFile file - (header, expr) <- throws (exprAndHeaderFromText "(stdin)" text)+ (header, expr) <- Dhall.Core.throws (exprAndHeaderFromText "(stdin)" text) let doc = Pretty.pretty header <> Pretty.unAnnotate (Dhall.Pretty.prettyCharacterSet characterSet expr)@@ -74,7 +74,7 @@ Nothing -> do inText <- Data.Text.IO.getContents - (header, expr) <- throws (exprAndHeaderFromText "(stdin)" inText)+ (header, expr) <- Dhall.Core.throws (exprAndHeaderFromText "(stdin)" inText) let doc = Pretty.pretty header <> Dhall.Pretty.prettyCharacterSet characterSet expr@@ -96,7 +96,7 @@ Just file -> Data.Text.IO.readFile file Nothing -> Data.Text.IO.getContents - (header, expr) <- throws (exprAndHeaderFromText "(stdin)" originalText)+ (header, expr) <- Dhall.Core.throws (exprAndHeaderFromText "(stdin)" originalText) let doc = Pretty.pretty header <> Pretty.unAnnotate (Dhall.Pretty.prettyCharacterSet characterSet expr)@@ -108,7 +108,3 @@ if originalText == formattedText then return () else Control.Exception.throwIO NotFormatted--throws :: (Exception e, MonadIO io) => Either e a -> io a-throws (Left e) = liftIO (Control.Exception.throwIO e)-throws (Right a) = return a
@@ -157,8 +157,6 @@ , ImportType(..) , ImportMode(..) , Import(..)- , ReifiedNormalizer(..)- , Scheme(..) , URL(..) ) #ifdef MIN_VERSION_http_client@@ -190,7 +188,6 @@ import qualified Dhall.Parser import qualified Dhall.Pretty.Internal import qualified Dhall.TypeCheck-import qualified Network.URI.Encode import qualified System.Environment import qualified System.Directory as Directory import qualified System.FilePath as FilePath@@ -311,7 +308,7 @@ <> concatMap (\e -> "\n" <> show e <> "\n") es throwMissingImport :: (MonadCatch m, Exception e) => e -> m a-throwMissingImport e = throwM (MissingImports [(toException e)])+throwMissingImport e = throwM (MissingImports [toException e]) -- | Exception thrown when a HTTP url is imported but dhall was built without -- the @with-http@ Cabal flag.@@ -464,6 +461,8 @@ exprFromImport here@(Import {..}) = do let ImportHashed {..} = importHashed + Status {..} <- State.get+ result <- Maybe.runMaybeT $ do Just expectedHash <- return hash cacheFile <- getCacheFile expectedHash@@ -475,13 +474,13 @@ if expectedHash == actualHash then return ()- else liftIO (Control.Exception.throwIO (HashMismatch {..}))+ else throwMissingImport (Imported _stack (HashMismatch {..})) let bytesLazy = Data.ByteString.Lazy.fromStrict bytesStrict - term <- throws (Codec.Serialise.deserialiseOrFail bytesLazy)+ term <- Dhall.Core.throws (Codec.Serialise.deserialiseOrFail bytesLazy) - throws (Dhall.Binary.decode term)+ Dhall.Core.throws (Dhall.Binary.decodeExpression term) case result of Just expression -> return expression@@ -509,12 +508,12 @@ Just expectedHash <- return hash cacheFile <- getCacheFile expectedHash - _ <- throws (Dhall.TypeCheck.typeWith _startingContext expression)+ _ <- Dhall.Core.throws (Dhall.TypeCheck.typeWith _startingContext expression) let normalizedExpression = Dhall.Core.alphaNormalize (Dhall.Core.normalizeWith- (getReifiedNormalizer _normalizer)+ _normalizer expression ) @@ -530,7 +529,7 @@ let fallback = do let actualHash = hashExpression NoVersion normalizedExpression - liftIO (Control.Exception.throwIO (HashMismatch {..}))+ throwMissingImport (Imported _stack (HashMismatch {..})) Data.Foldable.asum (map check [ minBound .. maxBound ]) <|> fallback @@ -612,28 +611,7 @@ return (path, text) - Remote (URL scheme authority path query fragment maybeHeaders) -> do- let prefix =- (case scheme of HTTP -> "http"; HTTPS -> "https")- <> "://"- <> authority-- let File {..} = path- let Directory {..} = directory-- let pathComponentToText component =- "/" <> Network.URI.Encode.encodeText component-- let fileText =- Text.concat- (map pathComponentToText (reverse components))- <> pathComponentToText file-- let suffix =- (case query of Nothing -> ""; Just q -> "?" <> q)- <> (case fragment of Nothing -> ""; Just f -> "#" <> f)- let url = Text.unpack (prefix <> fileText <> suffix)-+ Remote url@URL { headers = maybeHeaders } -> do mheaders <- case maybeHeaders of Nothing -> return Nothing Just importHashed_ -> do@@ -671,7 +649,9 @@ #ifdef MIN_VERSION_http_client fetchFromHttpUrl url mheaders #else- liftIO (throwIO (CannotImportHTTPURL url mheaders))+ let urlString = Text.unpack (Dhall.Core.pretty url)++ liftIO (throwIO (CannotImportHTTPURL urlString mheaders)) #endif Env env -> liftIO $ do@@ -820,7 +800,7 @@ -- cached, since they have already been checked expr''' <- case Dhall.TypeCheck.typeWith _startingContext expr'' of Left err -> throwM (Imported _stack' err)- Right _ -> return (Dhall.Core.normalizeWith (getReifiedNormalizer _normalizer) expr'')+ Right _ -> return (Dhall.Core.normalizeWith _normalizer expr'') zoom cache (State.modify' (Map.insert child (childNodeId, expr'''))) return expr''' @@ -852,7 +832,7 @@ throwM (SourcedException (Src begin end text₂) (MissingImports (es₀ ++ es₁))) where text₂ = text₀ <> " ? " <> text₁- + Const a -> pure (Const a) Var a -> pure (Var a) Lam a b c -> Lam <$> pure a <*> loadWith b <*> loadWith c@@ -909,8 +889,8 @@ OptionalBuild -> pure OptionalBuild Record a -> Record <$> mapM loadWith a RecordLit a -> RecordLit <$> mapM loadWith a- Union a -> Union <$> mapM loadWith a- UnionLit a b c -> UnionLit <$> pure a <*> loadWith b <*> mapM loadWith c+ Union a -> Union <$> mapM (mapM loadWith) a+ UnionLit a b c -> UnionLit <$> pure a <*> loadWith b <*> mapM (mapM loadWith) c Combine a b -> Combine <$> loadWith a <*> loadWith b CombineTypes a b -> CombineTypes <$> loadWith a <*> loadWith b Prefer a b -> Prefer <$> loadWith a <*> loadWith b@@ -977,8 +957,4 @@ -- | Assert than an expression is import-free assertNoImports :: MonadIO io => Expr Src Import -> io (Expr Src X) assertNoImports expression =- throws (traverse (\_ -> Left ImportResolutionDisabled) expression)--throws :: (Exception e, MonadIO io) => Either e a -> io a-throws (Left e) = liftIO (Control.Exception.throwIO e)-throws (Right a) = return a+ Dhall.Core.throws (traverse (\_ -> Left ImportResolutionDisabled) expression)
@@ -1,9 +1,10 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecordWildCards #-} module Dhall.Import.HTTP where +import Control.Exception (Exception) import Control.Monad (join) import Control.Monad.IO.Class (MonadIO(..)) import Control.Monad.Trans.State.Strict (StateT)@@ -11,17 +12,33 @@ import Data.CaseInsensitive (CI) import Data.Dynamic (fromDynamic, toDyn) import Data.Semigroup ((<>))+import Data.Text (Text) import Lens.Family.State.Strict (zoom) -import qualified Control.Monad.Trans.State.Strict as State-import qualified Data.Text as Text+import Dhall.Core+ ( Directory(..)+ , File(..)+ , Import(..)+ , ImportHashed(..)+ , ImportType(..)+ , Scheme(..)+ , URL(..)+ ) +import qualified Control.Monad.Trans.State.Strict as State+import qualified Data.Text as Text+import qualified Data.Text.Encoding+import qualified Dhall.Core+import qualified Dhall.Util+import qualified Network.URI.Encode as URI.Encode+ import Dhall.Import.Types +import qualified Control.Exception #ifdef __GHCJS__ import qualified JavaScript.XHR #else-import qualified Control.Exception+import qualified Data.List.NonEmpty as NonEmpty import qualified Data.Text.Lazy import qualified Data.Text.Lazy.Encoding #endif@@ -112,26 +129,138 @@ zoom manager (State.put (Just (toDyn m))) return m +data NotCORSCompliant = NotCORSCompliant+ { expectedOrigins :: [ByteString]+ , actualOrigin :: ByteString+ }++instance Exception NotCORSCompliant++instance Show NotCORSCompliant where+ show (NotCORSCompliant {..}) =+ Dhall.Util._ERROR <> ": Not CORS compliant\n"+ <> "\n"+ <> "Dhall supports transitive imports, meaning that an imported expression can\n"+ <> "import other expressions. However, a remote import (the \"parent\" import)\n"+ <> "cannot import another remote import (the \"child\" import) unless the child\n"+ <> "import grants permission to do using CORS. The child import must respond with\n"+ <> "an `Access-Control-Allow-Origin` response header that matches the parent\n"+ <> "import, otherwise Dhall rejects the import.\n"+ <> "\n" <> prologue+ where+ prologue =+ case expectedOrigins of+ [ expectedOrigin ] ->+ "The following parent import:\n"+ <> "\n"+ <> "↳ " <> show actualOrigin <> "\n"+ <> "\n"+ <> "... did not match the expected origin:\n"+ <> "\n"+ <> "↳ " <> show expectedOrigin <> "\n"+ <> "\n"+ <> "... so import resolution failed.\n"+ [] ->+ "The child response did not include any `Access-Control-Allow-Origin` header,\n"+ <> "so import resolution failed.\n"+ _:_:_ ->+ "The child response included more than one `Access-Control-Allow-Origin` header,\n"+ <> "when only one such header should have been present, so import resolution\n"+ <> "failed.\n"+ <> "\n"+ <> "This may indicate that the server for the child import is misconfigured.\n"++corsCompliant+ :: MonadIO io+ => ImportType -> URL -> [(CI ByteString, ByteString)] -> io ()+corsCompliant (Remote parentURL) childURL responseHeaders = liftIO $ do+ let toOrigin (URL {..}) =+ Data.Text.Encoding.encodeUtf8 (prefix <> "://" <> authority)+ where+ prefix =+ case scheme of+ HTTP -> "http"+ HTTPS -> "https"++ let actualOrigin = toOrigin parentURL++ let childOrigin = toOrigin childURL++ let predicate (header, _) = header == "Access-Control-Allow-Origin"++ let originHeaders = filter predicate responseHeaders++ let expectedOrigins = map snd originHeaders++ case expectedOrigins of+ [expectedOrigin]+ | expectedOrigin == "*" ->+ return ()+ | expectedOrigin == actualOrigin ->+ return ()+ _ | actualOrigin == childOrigin ->+ return ()+ | otherwise ->+ Control.Exception.throwIO (NotCORSCompliant {..})+corsCompliant _ _ _ = return ()++renderComponent :: Text -> Text+renderComponent component = "/" <> URI.Encode.encodeText component++renderQuery :: Text -> Text+renderQuery query = "?" <> query++renderURL :: URL -> Text+renderURL url =+ schemeText+ <> authority+ <> pathText+ <> queryText+ where+ URL {..} = url++ File {..} = path++ Directory {..} = directory++ schemeText = case scheme of+ HTTP -> "http://"+ HTTPS -> "https://"++ pathText =+ foldMap renderComponent (reverse components)+ <> renderComponent file++ queryText = foldMap renderQuery query+ fetchFromHttpUrl- :: String+ :: URL -> Maybe [(CI ByteString, ByteString)] -> StateT (Status m) IO (String, Text.Text) #ifdef __GHCJS__-fetchFromHttpUrl url Nothing = do- (statusCode, body) <- liftIO (JavaScript.XHR.get (Text.pack url))+fetchFromHttpUrl childURL Nothing = do+ let childURLText = Dhall.Core.pretty childURL + let childURLString = Text.unpack childURLText++ -- No need to add a CORS compliance check when using GHCJS. The browser+ -- will already check the CORS compliance of the following XHR+ (statusCode, body) <- liftIO (JavaScript.XHR.get childURLText)+ case statusCode of 200 -> return ()- _ -> fail (url <> " returned a non-200 status code: " <> show statusCode)+ _ -> fail (childURLString <> " returned a non-200 status code: " <> show statusCode) - return (url, body)+ return (childURLString, body) fetchFromHttpUrl _ _ = do fail "Dhall does not yet support custom headers when built using GHCJS" #else-fetchFromHttpUrl url mheaders = do+fetchFromHttpUrl childURL mheaders = do+ let childURLString = Text.unpack (Dhall.Core.pretty childURL)+ m <- needManager - request <- liftIO (HTTP.parseUrlThrow url)+ request <- liftIO (HTTP.parseUrlThrow childURLString) let requestWithHeaders = case mheaders of@@ -146,9 +275,17 @@ response <- liftIO (Control.Exception.handle handler io) + Status {..} <- State.get++ let parentImport = NonEmpty.head _stack++ let parentImportType = importType (importHashed parentImport)++ corsCompliant parentImportType childURL (HTTP.responseHeaders response)+ let bytes = HTTP.responseBody response case Data.Text.Lazy.Encoding.decodeUtf8' bytes of Left err -> liftIO (Control.Exception.throwIO err)- Right text -> return (url, Data.Text.Lazy.toStrict text)+ Right text -> return (childURLString, Data.Text.Lazy.toStrict text) #endif
@@ -56,7 +56,7 @@ , _standardVersion :: StandardVersion - , _normalizer :: ReifiedNormalizer X+ , _normalizer :: Maybe (ReifiedNormalizer X) , _startingContext :: Context (Expr Src X) @@ -85,7 +85,7 @@ _standardVersion = Dhall.Binary.defaultStandardVersion - _normalizer = ReifiedNormalizer (const (pure Nothing))+ _normalizer = Nothing _startingContext = Dhall.Context.empty @@ -135,8 +135,8 @@ standardVersion k s = fmap (\x -> s { _standardVersion = x }) (k (_standardVersion s)) -normalizer :: Functor f => LensLike' f (Status m) (ReifiedNormalizer X)-normalizer k s = fmap (\x -> s { _normalizer = x }) (k (_normalizer s))+normalizer :: Functor f => LensLike' f (Status m) (Maybe (ReifiedNormalizer X))+normalizer k s = fmap (\x -> s {_normalizer = x}) (k (_normalizer s)) startingContext :: Functor f => LensLike' f (Status m) (Context (Expr Src X)) startingContext k s =
@@ -20,7 +20,7 @@ ) where import Control.Applicative (optional, (<|>))-import Control.Exception (Exception, SomeException)+import Control.Exception (SomeException) import Data.Monoid ((<>)) import Data.Text (Text) import Data.Text.Prettyprint.Doc (Doc, Pretty)@@ -83,11 +83,11 @@ -- | The subcommands for the @dhall@ executable data Mode- = Default { annotate :: Bool }+ = Default { annotate :: Bool, alpha :: Bool } | Version | Resolve { resolveMode :: Maybe ResolveMode } | Type- | Normalize+ | Normalize { alpha :: Bool } | Repl | Format { formatMode :: Dhall.Format.FormatMode } | Freeze { inplace :: Maybe FilePath, all_ :: Bool }@@ -149,7 +149,7 @@ <|> subcommand "normalize" "Normalize an expression"- (pure Normalize)+ (Normalize <$> parseAlpha) <|> subcommand "repl" "Interpret expressions in a REPL"@@ -182,16 +182,24 @@ "decode" "Decode a Dhall expression from binary" (Decode <$> parseJSONFlag)- <|> (Default <$> parseAnnotate)+ <|> (Default <$> parseAnnotate <*> parseAlpha) where argument = fmap Data.Text.pack . Options.Applicative.strArgument . Options.Applicative.metavar + parseAlpha =+ Options.Applicative.switch+ ( Options.Applicative.long "alpha"+ <> Options.Applicative.help "α-normalize expression"+ )+ parseAnnotate = Options.Applicative.switch- (Options.Applicative.long "annotate")+ ( Options.Applicative.long "annotate"+ <> Options.Applicative.help "Add a type annotation to the output"+ ) parseResolveMode = Options.Applicative.flag' (Just Dot)@@ -243,15 +251,11 @@ adapt True path = Dhall.Format.Check {..} adapt False inplace = Dhall.Format.Modify {..} -throws :: Exception e => Either e a -> IO a-throws (Left e) = Control.Exception.throwIO e-throws (Right a) = return a- getExpression :: IO (Expr Src Import) getExpression = do inText <- Data.Text.IO.getContents - throws (Dhall.Parser.exprFromText "(stdin)" inText)+ Dhall.Core.throws (Dhall.Parser.exprFromText "(stdin)" inText) -- | `ParserInfo` for the `Options` type parserInfoOptions :: ParserInfo Options@@ -342,14 +346,19 @@ resolvedExpression <- State.evalStateT (Dhall.Import.loadWith expression) status - inferredType <- throws (Dhall.TypeCheck.typeOf resolvedExpression)+ inferredType <- Dhall.Core.throws (Dhall.TypeCheck.typeOf resolvedExpression) let normalizedExpression = Dhall.Core.normalize resolvedExpression + let alphaNormalizedExpression =+ if alpha+ then Dhall.Core.alphaNormalize normalizedExpression+ else normalizedExpression+ let annotatedExpression = if annotate- then Annot normalizedExpression inferredType- else normalizedExpression+ then Annot alphaNormalizedExpression inferredType+ else alphaNormalizedExpression render System.IO.stdout annotatedExpression @@ -390,21 +399,28 @@ State.runStateT (Dhall.Import.loadWith expression) status render System.IO.stdout resolvedExpression - Normalize -> do+ Normalize {..} -> do expression <- getExpression resolvedExpression <- Dhall.Import.assertNoImports expression - _ <- throws (Dhall.TypeCheck.typeOf resolvedExpression)+ _ <- Dhall.Core.throws (Dhall.TypeCheck.typeOf resolvedExpression) - render System.IO.stdout (Dhall.Core.normalize resolvedExpression)+ let normalizedExpression = Dhall.Core.normalize resolvedExpression + let alphaNormalizedExpression =+ if alpha+ then Dhall.Core.alphaNormalize normalizedExpression+ else normalizedExpression++ render System.IO.stdout alphaNormalizedExpression+ Type -> do expression <- getExpression resolvedExpression <- Dhall.Import.assertNoImports expression - inferredType <- throws (Dhall.TypeCheck.typeOf resolvedExpression)+ inferredType <- Dhall.Core.throws (Dhall.TypeCheck.typeOf resolvedExpression) render System.IO.stdout (Dhall.Core.normalize inferredType) @@ -434,7 +450,7 @@ Just file -> do text <- Data.Text.IO.readFile file - (header, expression) <- throws (Dhall.Parser.exprAndHeaderFromText file text)+ (header, expression) <- Dhall.Core.throws (Dhall.Parser.exprAndHeaderFromText file text) let lintedExpression = Dhall.Lint.lint expression @@ -447,7 +463,7 @@ Nothing -> do text <- Data.Text.IO.getContents - (header, expression) <- throws (Dhall.Parser.exprAndHeaderFromText "(stdin)" text)+ (header, expression) <- Dhall.Core.throws (Dhall.Parser.exprAndHeaderFromText "(stdin)" text) let lintedExpression = Dhall.Lint.lint expression @@ -467,7 +483,7 @@ then do let decoder = Codec.CBOR.JSON.decodeValue False - (_, value) <- throws (Codec.CBOR.Read.deserialiseFromBytes decoder bytes)+ (_, value) <- Dhall.Core.throws (Codec.CBOR.Read.deserialiseFromBytes decoder bytes) let jsonBytes = Data.Aeson.Encode.Pretty.encodePretty value @@ -489,11 +505,11 @@ let encoding = Codec.CBOR.JSON.encodeValue value let cborBytes = Codec.CBOR.Write.toLazyByteString encoding- throws (Codec.Serialise.deserialiseOrFail cborBytes)+ Dhall.Core.throws (Codec.Serialise.deserialiseOrFail cborBytes) else do- throws (Codec.Serialise.deserialiseOrFail bytes)+ Dhall.Core.throws (Codec.Serialise.deserialiseOrFail bytes) - expression <- throws (Dhall.Binary.decode term)+ expression <- Dhall.Core.throws (Dhall.Binary.decodeExpression term) let doc = Dhall.Pretty.prettyCharacterSet characterSet expression
@@ -33,7 +33,7 @@ -- | Parser for a top-level Dhall expression expr :: Parser (Expr Src Import)-expr = exprA import_+expr = exprA (Text.Megaparsec.try import_) -- | Parser for a top-level Dhall expression. The expression is parameterized -- over any parseable type, allowing the language to be extended as needed.
@@ -217,7 +217,7 @@ let left x e = Field e x let right xs e = Project e xs- b <- Text.Megaparsec.many (try (do _dot; fmap left label <|> fmap right labels))+ b <- Text.Megaparsec.many (try (do _dot; fmap left anyLabel <|> fmap right labels)) return (foldl (\e k -> k e) a b) ) primitiveExpression =@@ -532,14 +532,14 @@ alternative2 = return (Record mempty) nonEmptyRecordTypeOrLiteral = do- a <- label+ a <- anyLabel let nonEmptyRecordType = do _colon b <- expression e <- Text.Megaparsec.many (do _comma- c <- label+ c <- anyLabel _colon d <- expression return (c, d) )@@ -551,7 +551,7 @@ b <- expression e <- Text.Megaparsec.many (do _comma- c <- label+ c <- anyLabel _equal d <- expression return (c, d) )@@ -570,22 +570,20 @@ return (f m) where loop = do- a <- label+ a <- anyLabel let alternative0 = do _equal b <- expression kvs <- Text.Megaparsec.many (do _bar- c <- label- _colon- d <- expression+ c <- anyLabel+ d <- optional (do _colon; expression) return (c, d) ) return (UnionLit a b, kvs) let alternative1 = do- _colon- b <- expression+ b <- optional (do _colon; expression) let alternative2 = do _bar
@@ -8,6 +8,7 @@ posixEnvironmentVariable, file_, label,+ anyLabel, labels, httpRaw, hexdig,@@ -110,6 +111,7 @@ import qualified Data.List.NonEmpty import qualified Data.Text import qualified Dhall.Set+import qualified Network.URI.Encode as URI.Encode import qualified Text.Megaparsec import qualified Text.Megaparsec.Char.Lexer import qualified Text.Parser.Char@@ -268,12 +270,12 @@ blockCommentChunk blockCommentContinue -simpleLabel :: Parser Text-simpleLabel = try (do+simpleLabel :: Bool -> Parser Text+simpleLabel allowReserved = try (do c <- Text.Parser.Char.satisfy headCharacter rest <- Dhall.Parser.Combinators.takeWhile tailCharacter let text = Data.Text.cons c rest- Control.Monad.guard (not (Data.HashSet.member text reservedIdentifiers))+ Control.Monad.guard (allowReserved || not (Data.HashSet.member text reservedIdentifiers)) return text ) where headCharacter c = alpha c || c == '_'@@ -287,7 +289,9 @@ _ <- Text.Parser.Char.char '`' return t where- predicate c = alpha c || digit c || elem c ("$-/_:." :: String)+ predicate c =+ '\x20' <= c && c <= '\x5F'+ || '\x61' <= c && c <= '\x7E' labels :: Parser (Set Text) labels = do@@ -299,17 +303,23 @@ emptyLabels = pure Dhall.Set.empty nonEmptyLabels = do- x <- label- xs <- many (do _ <- _comma; label)+ x <- anyLabel+ xs <- many (do _ <- _comma; anyLabel) noDuplicates (x : xs) label :: Parser Text label = (do- t <- backtickLabel <|> simpleLabel+ t <- backtickLabel <|> simpleLabel False whitespace return t ) <?> "label" +anyLabel :: Parser Text+anyLabel = (do+ t <- backtickLabel <|> simpleLabel True+ whitespace+ return t ) <?> "any label"+ bashEnvironmentVariable :: Parser Text bashEnvironmentVariable = satisfy predicate0 <> star (satisfy predicate1) where@@ -371,10 +381,19 @@ httpRaw = do scheme <- scheme_ authority <- authority_- path <- file_+ oldPath <- file_ query <- optional (("?" :: Parser Text) *> query_)- fragment <- optional (("#" :: Parser Text) *> fragment_) + let path =+ oldPath+ { file = URI.Encode.decodeText (file oldPath)+ , directory =+ (directory oldPath)+ { components =+ map URI.Encode.decodeText (components (directory oldPath))+ }+ }+ let headers = Nothing return (URL {..})@@ -492,11 +511,6 @@ query_ :: Parser Text query_ = star (pchar <|> satisfy predicate)- where- predicate c = c == '/' || c == '?'--fragment_ :: Parser Text-fragment_ = star (pchar <|> satisfy predicate) where predicate c = c == '/' || c == '?'
@@ -20,6 +20,7 @@ , prettyConst , prettyLabel+ , prettyAnyLabel , prettyLabels , prettyNatural , prettyNumber@@ -300,22 +301,28 @@ tailCharacter :: Char -> Bool tailCharacter c = alpha c || digit c || c == '_' || c == '-' || c == '/' -prettyLabel :: Text -> Doc Ann-prettyLabel a = label doc+prettyLabelShared :: Bool -> Text -> Doc Ann+prettyLabelShared allowReserved a = label doc where doc = case Text.uncons a of Just (h, t)- | headCharacter h && Text.all tailCharacter t && not (Data.HashSet.member a reservedIdentifiers)+ | headCharacter h && Text.all tailCharacter t && (allowReserved || not (Data.HashSet.member a reservedIdentifiers)) -> Pretty.pretty a _ -> backtick <> Pretty.pretty a <> backtick +prettyLabel :: Text -> Doc Ann+prettyLabel = prettyLabelShared False++prettyAnyLabel :: Text -> Doc Ann+prettyAnyLabel = prettyLabelShared True+ prettyLabels :: Set Text -> Doc Ann prettyLabels a | Data.Set.null (Dhall.Set.toSet a) = lbrace <> rbrace | otherwise =- braces (map (duplicate . prettyLabel) (Dhall.Set.toList a))+ braces (map (duplicate . prettyAnyLabel) (Dhall.Set.toList a)) prettyNumber :: Integer -> Doc Ann prettyNumber = literal . Pretty.pretty@@ -724,7 +731,7 @@ prettySelectorExpression :: Pretty a => Expr s a -> Doc Ann prettySelectorExpression (Field a b) =- prettySelectorExpression a <> dot <> prettyLabel b+ prettySelectorExpression a <> dot <> prettyAnyLabel b prettySelectorExpression (Project a b) = prettySelectorExpression a <> dot <> prettyLabels b prettySelectorExpression (Note _ b) =@@ -829,10 +836,14 @@ prettyKeyValue :: Pretty a => Doc Ann -> (Text, Expr s a) -> (Doc Ann, Doc Ann) prettyKeyValue separator (key, val) =- ( prettyLabel key <> " " <> separator <> " " <> prettyExpression val- , prettyLabel key+ ( prettyAnyLabel key <> " " <> separator+ <> " "+ <> prettyExpression val+ , prettyAnyLabel key+ <> " "+ <> separator <> long ) where@@ -849,18 +860,20 @@ | otherwise = braces (map (prettyKeyValue equals) (Dhall.Map.toList a)) - prettyUnion :: Pretty a => Map Text (Expr s a) -> Doc Ann+ prettyAlternative (key, Just val) = prettyKeyValue colon (key, val)+ prettyAlternative (key, Nothing ) = duplicate (prettyAnyLabel key)++ prettyUnion :: Pretty a => Map Text (Maybe (Expr s a)) -> Doc Ann prettyUnion =- angles . map (prettyKeyValue colon) . Dhall.Map.toList+ angles . map prettyAlternative . Dhall.Map.toList prettyUnionLit- :: Pretty a => Text -> Expr s a -> Map Text (Expr s a) -> Doc Ann+ :: Pretty a+ => Text -> Expr s a -> Map Text (Maybe (Expr s a)) -> Doc Ann prettyUnionLit a b c =- angles (front : map adapt (Dhall.Map.toList c))+ angles (front : map prettyAlternative (Dhall.Map.toList c)) where front = prettyKeyValue equals (a, b)-- adapt = prettyKeyValue colon prettyChunks :: Pretty a => Chunks s a -> Doc Ann prettyChunks (Chunks a b) =
@@ -480,23 +480,28 @@ where listCompletion = map simpleCompletion . filter (word `isPrefixOf`) - algebraicComplete :: [Text.Text] -> Dhall.Expr Dhall.Src Dhall.X -> [Text.Text]+ algebraicComplete+ :: [Text.Text] -> Dhall.Expr Dhall.Src Dhall.X -> [Text.Text] algebraicComplete subFields expr = let keys = fmap ("." <>) . Map.keys - withMap m- | [] <- subFields = keys m- -- Stop on last subField (we care about the keys at this level)- | [_] <- subFields = keys m- | f:fs <- subFields =- maybe- []- (fmap (("." <> f) <>) . algebraicComplete fs)- (Map.lookup f m)+ withMap m =+ case subFields of+ [] -> keys m+ -- Stop on last subField (we care about the keys at this level)+ [_] -> keys m+ f:fs ->+ case Map.lookup f m of+ Nothing ->+ []+ Just Nothing ->+ keys m+ Just (Just e) ->+ fmap (("." <> f) <>) (algebraicComplete fs e) in case expr of- Dhall.Core.Record m -> withMap m- Dhall.Core.RecordLit m -> withMap m+ Dhall.Core.Record m -> withMap (fmap Just m)+ Dhall.Core.RecordLit m -> withMap (fmap Just m) Dhall.Core.Union m -> withMap m Dhall.Core.UnionLit _ _ m -> withMap m _ -> []
@@ -1060,18 +1060,36 @@ -- the @Natural@ alternative and the @Right@ tag is used for the @Bool@ -- alternative. ----- A union literal specifies the value of one alternative and the types of the--- remaining alternatives. For example, both of the following union literals--- have the same type, which is the above union type:+-- You can specify the value of a union constructor like this: ----- > < Left = 0 | Right : Bool >+-- > let Union = < Left : Natural | Right : Bool>+-- > +-- > [ Union.Left 0, Union.Right True ] : List Union ----- > < Right = True | Left : Natural >+-- In other words, you can access a union constructor as a field of a union+-- type and use that constructor to wrap a value of a type appropriate for+-- that alternative. In the above example, the @Left@ constructor can wrap+-- a @Natural@ value and the @Right@ constructor can wrap a @Bool@ value. We+-- can also confirm that by inspecting their type: --+-- > $ echo '< Left : Natural | Right : Bool>' > ./Union+--+-- > $ dhall --annotate <<< '(./Union).Left'+-- > < Left : Natural | Right : Bool >.Left+-- > : ∀(Left : Natural) → < Left : Natural | Right : Bool >+--+-- > $ dhall --annotate <<< '(./Union).Right'+-- > < Left : Natural | Right : Bool >.Right+-- > : ∀(Right : Bool) → < Left : Natural | Right : Bool >+--+-- In other words, the @Left@ constructor is a function from a @Natural@ to a+-- value of our @Union@ type and the @Right@ constructor is a separate function+-- from a @Bool@ to that same @Union@ type.+-- -- You can consume a union using the built-in @merge@ function. For example, -- suppose we want to convert our union to a @Bool@ but we want to behave -- differently depending on whether or not the union is a @Natural@ wrapped in--- the @Left@ alternative or a @Bool@ wrapped in the @Right@ alternative. We+-- the @Left@ constructor or a @Bool@ wrapped in the @Right@ constructor . We -- would write: -- -- > $ cat > process <<EOF@@ -1085,18 +1103,10 @@ -- -- Now our @./process@ function can handle both alternatives: ----- > $ dhall--- > ./process < Left = 3 | Right : Bool >--- > <Ctrl-D>--- > Bool--- > +-- > $ dhall <<< './process ((./Union).Left 3)' -- > False ----- > $ dhall--- > ./process < Right = True | Left : Natural >--- > <Ctrl-D>--- > Bool--- > +-- > $ dhall <<< './process ((./Union).Right True)' -- > True -- -- Every @merge@ has the following form:@@ -1112,66 +1122,54 @@ -- The @merge@ function selects which function to apply from the record based on -- which alternative the union selects: ----- > merge { Foo = f, ... } < Foo = x | ... > : t = f x : t+-- > merge { Foo = f, ... } (< … >.Foo x) = f x -- -- So, for example: ----- > merge { Left = Natural/even, Right = λ(b : Bool) → b } < Left = 3 | Right : Bool > : Bool--- > = Natural/even 3 : Bool+-- > merge { Left = Natural/even, Right = λ(b : Bool) → b } (< Left : Natural | Right : Bool >.Left 3)+-- > = Natural/even 3 -- > = False -- -- ... and similarly: ----- > merge { Left = Natural/even, Right = λ(b : Bool) → b } < Right = True | Left : Natural > : Bool--- > = (λ(b : Bool) → b) True : Bool+-- > merge { Left = Natural/even, Right = λ(b : Bool) → b } (< Left : Natural | Right : Bool >.Right True)+-- > = (λ(b : Bool) → b) True -- > = True -- -- Notice that each handler has to return the same type of result (@Bool@ in--- this case) which must also match the declared result type of the @merge@.+-- this case). ----- You can also omit the type annotation when merging a union with one or more--- alternatives, like this:+-- You can also store more than one value within alternatives using Dhall's+-- support for anonymous records. You can nest an anonymous record within a+-- union such as in this type: ----- > merge { Left = Natural/even, Right = λ(b : Bool) → b } < Right = True | Left : Natural >+-- > < Empty : {} | Person : { name : Text, age : Natural } > ----- You can also store more than one value or less than one value within--- alternatives using Dhall's support for anonymous records. You can nest an--- anonymous record within a union such as in this type:+-- You can even go a step further and omit the type of an alternative if it+-- stores no data, like this: ----- > < Empty : {} | Person : { name : Text, age : Natural } >+-- > < Empty | Person : { name : Text, age : Natural } > --+-- -- This union of records resembles following equivalent Haskell data type: -- -- > data Example = Empty | Person { name :: Text, age :: Text } ----- You could resemble Haskell further by defining convenient constructors for--- each alternative, like this:------ > let Empty = < Empty = {=} | Person : { name : Text, age : Natural } >--- > let Person =--- > λ(p : { name : Text, age : Natural }) → < Person = p | Empty : {} >--- > in [ Empty--- > , Person { name = "John", age = 23 }--- > , Person { name = "Amy" , age = 25 }--- > , Empty--- > ]------ ... but there is no need to do so, since the Dhall language auto-generates--- constructors for each alternative. You can access each constructor as if it--- were a field of the union type:+-- Empty alternatives like @Empty@ require no argument: ----- > let MyType = < Empty : {} | Person : { name : Text, age : Natural } >--- > in [ MyType.Empty {=}+-- > let MyType = < Empty | Person : { name : Text, age : Natural } >+-- > +-- > in [ MyType.Empty -- Note the absence of any argument to `Empty` -- > , MyType.Person { name = "John", age = 23 } -- > , MyType.Person { name = "Amy" , age = 25 } -- > ] ----- You can also extract fields during pattern matching such as in the following--- function which renders each value to `Text`:+-- ... and when you @merge@ an empty alternative the correspond handler takes no+-- argument: ----- > λ(x : < Empty : {} | Person : { name : Text, age : Natural } >)+-- > λ(x : < Empty | Person : { name : Text, age : Natural } >) -- > → merge--- > { Empty = λ(_ : {}) → "Unknown"+-- > { Empty = "Unknown" -- Note the absence of a `λ` -- > -- > , Person = -- > λ(person : { name : Text, age : Natural })
@@ -21,10 +21,12 @@ , TypeMessage(..) ) where +import Control.Applicative (empty) import Control.Exception (Exception) import Data.Data (Data(..)) import Data.Foldable (forM_, toList) import Data.List.NonEmpty (NonEmpty(..))+import Data.Monoid (First(..)) import Data.Sequence (Seq, ViewL(..)) import Data.Semigroup (Semigroup(..)) import Data.Set (Set)@@ -32,6 +34,7 @@ import Data.Text.Prettyprint.Doc (Doc, Pretty(..)) import Data.Traversable (forM) import Data.Typeable (Typeable)+import Dhall.Binary (FromTerm(..), ToTerm(..)) import Dhall.Core (Binding(..), Const(..), Chunks(..), Expr(..), Var(..)) import Dhall.Context (Context) import Dhall.Pretty (Ann, layoutOpts)@@ -484,34 +487,16 @@ Just (k0, t0, rest) -> do s0 <- fmap Dhall.Core.normalize (loop ctx t0) c <- case s0 of- Const Type ->- return Type- Const Kind ->- return Kind- Const Sort- | Dhall.Core.judgmentallyEqual t0 (Const Kind) ->- return Sort+ Const c -> pure c _ -> Left (TypeError ctx e (InvalidFieldType k0 t0)) let process k t = do s <- fmap Dhall.Core.normalize (loop ctx t) case s of- Const Type ->- if c == Type- then return ()- else Left (TypeError ctx e (FieldAnnotationMismatch k t c k0 t0 Type))- Const Kind ->- if c == Kind+ Const c' ->+ if c == c' then return ()- else Left (TypeError ctx e (FieldAnnotationMismatch k t c k0 t0 Kind))- Const Sort ->- if c == Sort- then- if Dhall.Core.judgmentallyEqual t (Const Kind)- then return ()- else Left (TypeError ctx e (InvalidFieldType k t))- else Left (TypeError ctx e (FieldAnnotationMismatch k t c k0 t0 Sort))- _ ->- Left (TypeError ctx e (InvalidFieldType k t))+ else Left (TypeError ctx e (FieldAnnotationMismatch k t c k0 t0 c'))+ _ -> Left (TypeError ctx e (InvalidFieldType k t)) Dhall.Map.unorderedTraverseWithKey_ process rest return (Const c) loop ctx e@(RecordLit kvs ) = do@@ -521,45 +506,29 @@ t0 <- loop ctx v0 s0 <- fmap Dhall.Core.normalize (loop ctx t0) c <- case s0 of- Const Type ->- return Type- Const Kind ->- return Kind- Const Sort- | Dhall.Core.judgmentallyEqual t0 (Const Kind) ->- return Sort+ Const c -> pure c _ -> Left (TypeError ctx e (InvalidField k0 v0)) let process k v = do t <- loop ctx v s <- fmap Dhall.Core.normalize (loop ctx t) case s of- Const Type ->- if c == Type- then return ()- else Left (TypeError ctx e (FieldMismatch k v c k0 v0 Type))- Const Kind ->- if c == Kind+ Const c' ->+ if c == c' then return ()- else Left (TypeError ctx e (FieldMismatch k v c k0 v0 Kind))- Const Sort ->- if c == Sort- then- if Dhall.Core.judgmentallyEqual t (Const Kind)- then return ()- else Left (TypeError ctx e (InvalidField k t))- else Left (TypeError ctx e (FieldMismatch k v c k0 v0 Sort))- _ ->- Left (TypeError ctx e (InvalidField k t))+ else Left (TypeError ctx e (FieldMismatch k v c k0 v0 c'))+ _ -> Left (TypeError ctx e (InvalidField k t)) return t kts <- Dhall.Map.traverseWithKey process kvs return (Record kts) loop ctx e@(Union kts ) = do- case Dhall.Map.uncons kts of+ let nonEmpty k mt = First (fmap (\t -> (k, t)) mt)++ case getFirst (Dhall.Map.foldMapWithKey nonEmpty kts) of Nothing -> do return (Const Type) - Just (k0, t0, rest) -> do+ Just (k0, t0) -> do s0 <- fmap Dhall.Core.normalize (loop ctx t0) c0 <- case s0 of@@ -569,7 +538,10 @@ _ -> do Left (TypeError ctx e (InvalidAlternativeType k0 t0)) - let process k t = do+ let process _ Nothing = do+ return ()++ process k (Just t) = do s <- fmap Dhall.Core.normalize (loop ctx t) c <- case s of@@ -583,7 +555,7 @@ then return () else Left (TypeError ctx e (AlternativeAnnotationMismatch k t c k0 t0 c0)) - Dhall.Map.unorderedTraverseWithKey_ process rest+ Dhall.Map.unorderedTraverseWithKey_ process kts return (Const c0) loop ctx e@(UnionLit k v kts) = do@@ -591,7 +563,7 @@ Just _ -> Left (TypeError ctx e (DuplicateAlternative k)) Nothing -> return () t <- loop ctx v- let union = Union (Dhall.Map.insert k (Dhall.Core.normalize t) kts)+ let union = Union (Dhall.Map.insert k (Just (Dhall.Core.normalize t)) kts) _ <- loop ctx union return union loop ctx e@(Combine kvsX kvsY) = do@@ -711,19 +683,20 @@ else Left (TypeError ctx e (RecordMismatch '⫽' kvsX kvsY constX constY)) return (Record (Dhall.Map.union ktsY ktsX))- loop ctx e@(Merge kvsX kvsY (Just t)) = do- _ <- loop ctx t-+ loop ctx e@(Merge kvsX kvsY mT₁) = do tKvsX <- fmap Dhall.Core.normalize (loop ctx kvsX)- ktsX <- case tKvsX of++ ktsX <- case tKvsX of Record kts -> return kts _ -> Left (TypeError ctx e (MustMergeARecord kvsX tKvsX))- let ksX = Data.Set.fromList (Dhall.Map.keys ktsX) tKvsY <- fmap Dhall.Core.normalize (loop ctx kvsY)- ktsY <- case tKvsY of++ ktsY <- case tKvsY of Union kts -> return kts _ -> Left (TypeError ctx e (MustMergeUnion kvsY tKvsY))++ let ksX = Data.Set.fromList (Dhall.Map.keys ktsX) let ksY = Data.Set.fromList (Dhall.Map.keys ktsY) let diffX = Data.Set.difference ksX ksY@@ -733,62 +706,69 @@ then return () else Left (TypeError ctx e (UnusedHandler diffX)) - let process (kY, tY) = do- case Dhall.Map.lookup kY ktsX of- Nothing -> Left (TypeError ctx e (MissingHandler diffY))- Just tX ->- case tX of- Pi y tY' t' -> do- if Dhall.Core.judgmentallyEqual tY tY'- then return ()- else Left (TypeError ctx e (HandlerInputTypeMismatch kY tY tY'))- let t'' = Dhall.Core.shift (-1) (V y 0) t'- if Dhall.Core.judgmentallyEqual t t''- then return ()- else Left (TypeError ctx e (InvalidHandlerOutputType kY t t''))- _ -> Left (TypeError ctx e (HandlerNotAFunction kY tX))- mapM_ process (Dhall.Map.toList ktsY)- return t- loop ctx e@(Merge kvsX kvsY Nothing) = do- tKvsX <- fmap Dhall.Core.normalize (loop ctx kvsX)- ktsX <- case tKvsX of- Record kts -> return kts- _ -> Left (TypeError ctx e (MustMergeARecord kvsX tKvsX))- let ksX = Data.Set.fromList (Dhall.Map.keys ktsX)+ (mKX, _T₁) <- do+ case mT₁ of+ Just _T₁ -> do+ return (Nothing, _T₁) - tKvsY <- fmap Dhall.Core.normalize (loop ctx kvsY)- ktsY <- case tKvsY of- Union kts -> return kts- _ -> Left (TypeError ctx e (MustMergeUnion kvsY tKvsY))- let ksY = Data.Set.fromList (Dhall.Map.keys ktsY)+ Nothing -> do+ case Dhall.Map.uncons ktsX of+ Nothing -> do+ Left (TypeError ctx e MissingMergeType) - let diffX = Data.Set.difference ksX ksY- let diffY = Data.Set.difference ksY ksX+ Just (kX, tX, _) -> do+ _T₁ <- do+ case Dhall.Map.lookup kX ktsY of+ Nothing -> do+ Left (TypeError ctx e (UnusedHandler diffX)) - if Data.Set.null diffX- then return ()- else Left (TypeError ctx e (UnusedHandler diffX))+ Just Nothing -> do+ return tX - (kX, t) <- case Dhall.Map.toList ktsX of- [] -> Left (TypeError ctx e MissingMergeType)- (kX, Pi y _ t):_ -> return (kX, Dhall.Core.shift (-1) (V y 0) t)- (kX, tX ):_ -> Left (TypeError ctx e (HandlerNotAFunction kX tX))- let process (kY, tY) = do+ Just (Just _) ->+ case tX of+ Pi x _A₀ _T₀ -> do+ return (Dhall.Core.shift (-1) (V x 0) _T₀)+ _ -> do+ Left (TypeError ctx e (HandlerNotAFunction kX tX))++ return (Just kX, _T₁)++ _ <- loop ctx _T₁++ let process kY mTY = do case Dhall.Map.lookup kY ktsX of- Nothing -> Left (TypeError ctx e (MissingHandler diffY))- Just tX ->- case tX of- Pi y tY' t' -> do- if Dhall.Core.judgmentallyEqual tY tY'- then return ()- else Left (TypeError ctx e (HandlerInputTypeMismatch kY tY tY'))- let t'' = Dhall.Core.shift (-1) (V y 0) t'- if Dhall.Core.judgmentallyEqual t t''- then return ()- else Left (TypeError ctx e (HandlerOutputTypeMismatch kX t kY t''))- _ -> Left (TypeError ctx e (HandlerNotAFunction kY tX))- mapM_ process (Dhall.Map.toList ktsY)- return t+ Nothing -> do+ Left (TypeError ctx e (MissingHandler diffY))++ Just tX -> do+ _T₃ <- do+ case mTY of+ Nothing -> do+ return tX+ Just _A₁ -> do+ case tX of+ Pi x _A₀ _T₂ -> do+ if Dhall.Core.judgmentallyEqual _A₀ _A₁+ then return ()+ else Left (TypeError ctx e (HandlerInputTypeMismatch kY _A₁ _A₀))++ return (Dhall.Core.shift (-1) (V x 0) _T₂)+ _ -> do+ Left (TypeError ctx e (HandlerNotAFunction kY tX))++ if Dhall.Core.judgmentallyEqual _T₁ _T₃+ then return ()+ else+ case mKX of+ Nothing -> do+ Left (TypeError ctx e (InvalidHandlerOutputType kY _T₁ _T₃))+ Just kX -> do+ Left (TypeError ctx e (HandlerOutputTypeMismatch kX _T₁ kY _T₃))++ Dhall.Map.unorderedTraverseWithKey_ process ktsY++ return _T₁ loop ctx e@(Field r x ) = do t <- fmap Dhall.Core.normalize (loop ctx r) @@ -805,7 +785,8 @@ case Dhall.Core.normalize r of Union kts -> case Dhall.Map.lookup x kts of- Just t' -> return (Pi x t' (Union kts))+ Just (Just t') -> return (Pi x t' (Union kts))+ Just Nothing -> return (Union kts) Nothing -> Left (TypeError ctx e (MissingField x t)) r' -> Left (TypeError ctx e (CantAccess text r' t)) _ -> do@@ -857,6 +838,12 @@ instance Pretty X where pretty = absurd +instance FromTerm X where+ decode _ = empty++instance ToTerm X where+ encode = absurd+ -- | The specific type error data TypeMessage s a = UnboundVariable Text@@ -915,13 +902,13 @@ | NoDependentTypes (Expr s a) (Expr s a) deriving (Show) -shortTypeMessage :: (Eq a, Pretty a) => TypeMessage s a -> Doc Ann+shortTypeMessage :: (Eq a, Pretty a, ToTerm a) => TypeMessage s a -> Doc Ann shortTypeMessage msg = "\ESC[1;31mError\ESC[0m: " <> short <> "\n" where ErrorMessages {..} = prettyTypeMessage msg -longTypeMessage :: (Eq a, Pretty a) => TypeMessage s a -> Doc Ann+longTypeMessage :: (Eq a, Pretty a, ToTerm a) => TypeMessage s a -> Doc Ann longTypeMessage msg = "\ESC[1;31mError\ESC[0m: " <> short <> "\n" <> "\n"@@ -942,10 +929,11 @@ insert :: Pretty a => a -> Doc Ann insert = Dhall.Util.insert -prettyDiff :: (Eq a, Pretty a) => Expr s a -> Expr s a -> Doc Ann+prettyDiff :: (Eq a, Pretty a, ToTerm a) => Expr s a -> Expr s a -> Doc Ann prettyDiff exprL exprR = Dhall.Diff.diffNormalized exprL exprR -prettyTypeMessage :: (Eq a, Pretty a) => TypeMessage s a -> ErrorMessages+prettyTypeMessage+ :: (Eq a, Pretty a, ToTerm a) => TypeMessage s a -> ErrorMessages prettyTypeMessage (UnboundVariable x) = ErrorMessages {..} -- We do not need to print variable name here. For the discussion see: -- https://github.com/dhall-lang/dhall-haskell/pull/116@@ -3763,12 +3751,12 @@ , typeMessage :: TypeMessage s a } -instance (Eq a, Pretty s, Pretty a) => Show (TypeError s a) where+instance (Eq a, Pretty s, Pretty a, ToTerm a) => Show (TypeError s a) where show = Pretty.renderString . Pretty.layoutPretty layoutOpts . Pretty.pretty -instance (Eq a, Pretty s, Pretty a, Typeable s, Typeable a) => Exception (TypeError s a)+instance (Eq a, Pretty s, Pretty a, ToTerm a, Typeable s, Typeable a) => Exception (TypeError s a) -instance (Eq a, Pretty s, Pretty a) => Pretty (TypeError s a) where+instance (Eq a, Pretty s, Pretty a, ToTerm a) => Pretty (TypeError s a) where pretty (TypeError ctx expr msg) = Pretty.unAnnotate ( "\n"@@ -3799,12 +3787,12 @@ newtype DetailedTypeError s a = DetailedTypeError (TypeError s a) deriving (Typeable) -instance (Eq a, Pretty s, Pretty a) => Show (DetailedTypeError s a) where+instance (Eq a, Pretty s, Pretty a, ToTerm a) => Show (DetailedTypeError s a) where show = Pretty.renderString . Pretty.layoutPretty layoutOpts . Pretty.pretty -instance (Eq a, Pretty s, Pretty a, Typeable s, Typeable a) => Exception (DetailedTypeError s a)+instance (Eq a, Pretty s, Pretty a, ToTerm a, Typeable s, Typeable a) => Exception (DetailedTypeError s a) -instance (Eq a, Pretty s, Pretty a) => Pretty (DetailedTypeError s a) where+instance (Eq a, Pretty s, Pretty a, ToTerm a) => Pretty (DetailedTypeError s a) where pretty (DetailedTypeError (TypeError ctx expr msg)) = Pretty.unAnnotate ( "\n"
@@ -6,9 +6,11 @@ ( snip , snipDoc , insert+ , _ERROR ) where import Data.Monoid ((<>))+import Data.String (IsString) import Data.Text (Text) import Data.Text.Prettyprint.Doc (Doc, Pretty) import Dhall.Pretty (Ann)@@ -73,3 +75,7 @@ insert :: Pretty a => a -> Doc Ann insert expression = "↳ " <> Pretty.align (snipDoc (Pretty.pretty expression))++-- | Prefix used for error messages+_ERROR :: IsString string => string+_ERROR = "\ESC[1;31mError\ESC[0m"
@@ -7,108 +7,59 @@ import Dhall.Pretty (CharacterSet(..)) import Test.Tasty (TestTree) -import qualified Control.Exception-import qualified Data.Text-import qualified Data.Text.IO-import qualified Data.Text.Prettyprint.Doc-import qualified Data.Text.Prettyprint.Doc.Render.Text-import qualified Dhall.Parser-import qualified Dhall.Pretty-import qualified Test.Tasty-import qualified Test.Tasty.HUnit+import qualified Control.Monad as Monad+import qualified Data.Text as Text+import qualified Data.Text.IO as Text.IO+import qualified Data.Text.Prettyprint.Doc as Doc+import qualified Data.Text.Prettyprint.Doc.Render.Text as Doc.Render.Text+import qualified Dhall.Core as Core+import qualified Dhall.Parser as Parser+import qualified Dhall.Pretty as Pretty+import qualified Dhall.Test.Util as Test.Util+import qualified Test.Tasty as Tasty+import qualified Test.Tasty.HUnit as Tasty.HUnit+import qualified Turtle -tests :: TestTree-tests =- Test.Tasty.testGroup "format tests"- [ should- Unicode- "prefer multi-line strings when newlines present"- "multiline"- , should- Unicode- "escape ${ for single-quoted strings"- "escapeSingleQuotedOpenInterpolation"- , should- Unicode- "preserve the original order of fields"- "fieldOrder"- , should- Unicode- "preserve the original order of projections"- "projectionOrder"- , should- Unicode- "escape numeric labels correctly"- "escapeNumericLabel"- , should- Unicode- "correctly handle scientific notation with a large exponent"- "largeExponent"- , should- Unicode- "round a double to the nearest representable value. Ties go to even least significant bit"- "doubleRound"- , should- Unicode- "correctly format the empty record literal"- "emptyRecord"- , should- Unicode- "indent then/else to the same column"- "ifThenElse"- , should- Unicode- "handle indenting long imports correctly without trailing space per line"- "importLines"- , should- Unicode- "handle indenting small imports correctly without trailing space inline"- "importLines2"- , should- Unicode- "not remove parentheses when accessing a field of a record"- "importAccess"- , should- Unicode- "handle formatting sha256 imports correctly"- "sha256Printing"- , should- Unicode- "handle formatting of Import suffix correctly"- "importSuffix"- , should- ASCII- "be able to format with ASCII characters"- "ascii"- , should- Unicode- "preserve Unicode characters"- "unicode"- , should- Unicode- "not replace `../` with `./../`"- "parent"- ]+getTests :: IO TestTree+getTests = do+ let unicodeFiles = do+ path <- Turtle.lstree "./tests/format" -should :: CharacterSet -> Text -> Text -> TestTree-should characterSet name basename =- Test.Tasty.HUnit.testCase (Data.Text.unpack name) $ do- let inputFile =- Data.Text.unpack ("./tests/format/" <> basename <> "A.dhall")- let outputFile =- Data.Text.unpack ("./tests/format/" <> basename <> "B.dhall")- inputText <- Data.Text.IO.readFile inputFile+ let skip = [ "./tests/format/asciiA.dhall" ] - expr <- case Dhall.Parser.exprFromText mempty inputText of- Left err -> Control.Exception.throwIO err- Right expr -> return expr+ Monad.guard (path `notElem` skip) - let doc = Dhall.Pretty.prettyCharacterSet characterSet expr- let docStream = Data.Text.Prettyprint.Doc.layoutSmart Dhall.Pretty.layoutOpts doc- let actualText = Data.Text.Prettyprint.Doc.Render.Text.renderStrict docStream+ return path - expectedText <- Data.Text.IO.readFile outputFile+ unicodeTests <- Test.Util.discover (Turtle.chars <* "A.dhall") (formatTest Unicode) unicodeFiles + asciiTests <- Test.Util.discover (Turtle.chars <* "A.dhall") (formatTest ASCII) (pure "./tests/format/asciiA.dhall")++ let testTree =+ Tasty.testGroup "format tests"+ [ unicodeTests+ , asciiTests+ ]++ return testTree++formatTest :: CharacterSet -> Text -> TestTree+formatTest characterSet prefix =+ Tasty.HUnit.testCase (Text.unpack prefix) $ do+ let inputFile = Text.unpack (prefix <> "A.dhall")+ let outputFile = Text.unpack (prefix <> "B.dhall")++ inputText <- Text.IO.readFile inputFile++ expr <- Core.throws (Parser.exprFromText mempty inputText)++ let doc = Pretty.prettyCharacterSet characterSet expr+ let docStream = Doc.layoutSmart Pretty.layoutOpts doc+ let actualText = Doc.Render.Text.renderStrict docStream++ expectedText <- Text.IO.readFile outputFile+ let message = "The formatted expression did not match the expected output"- Test.Tasty.HUnit.assertEqual message expectedText actualText++ Tasty.HUnit.assertEqual message expectedText actualText
@@ -2,92 +2,71 @@ module Dhall.Test.Import where +import Control.Exception (catch)+import Data.Monoid ((<>)) import Data.Text (Text)-import Test.Tasty (TestTree) import Dhall.Import (MissingImports(..)) import Dhall.Parser (SourcedException(..))-import Control.Exception (catch, throwIO)-import Data.Monoid ((<>))+import Prelude hiding (FilePath)+import Test.Tasty (TestTree)+import Turtle (FilePath, (</>)) import qualified Control.Monad.Trans.State.Strict as State-import qualified Data.Text-import qualified Data.Text.IO-import qualified Dhall.Parser-import qualified Dhall.Import-import qualified Test.Tasty-import qualified Test.Tasty.HUnit+import qualified Data.Text as Text+import qualified Data.Text.IO as Text.IO+import qualified Dhall.Core as Core+import qualified Dhall.Import as Import+import qualified Dhall.Parser as Parser+import qualified Dhall.Test.Util as Test.Util+import qualified System.FilePath as FilePath+import qualified Test.Tasty as Tasty+import qualified Test.Tasty.HUnit as Tasty.HUnit+import qualified Turtle -tests :: TestTree-tests =- Test.Tasty.testGroup "import tests"- [ Test.Tasty.testGroup "import alternatives"- [ shouldFail- 3- "alternative of several unset env variables"- "./dhall-lang/tests/import/failure/alternativeEnv.dhall"- , shouldFail- 1- "alternative of env variable and missing"- "./dhall-lang/tests/import/failure/alternativeEnvMissing.dhall"- , shouldFail- 0- "just missing"- "./dhall-lang/tests/import/failure/missing.dhall"- , shouldNotFail- "alternative of env variable, missing, and a Natural"- "./dhall-lang/tests/import/success/alternativeEnvNaturalA.dhall"- , shouldNotFail- "alternative of env variable and a Natural"- "./dhall-lang/tests/import/success/alternativeEnvSimpleA.dhall"- , shouldNotFail- "alternative of a Natural and missing"- "./dhall-lang/tests/import/success/alternativeNaturalA.dhall"- ]- , Test.Tasty.testGroup "import relative to argument"- [ shouldNotFailRelative- "a semantic integrity check if fields are reordered"- "./dhall-lang/tests/import/success/"- "./dhall-lang/tests/import/success/fieldOrderA.dhall"- ]- ]+importDirectory :: FilePath+importDirectory = "./dhall-lang/tests/import" -shouldNotFail :: Text -> FilePath -> TestTree-shouldNotFail name path = Test.Tasty.HUnit.testCase (Data.Text.unpack name) (do- text <- Data.Text.IO.readFile path- actualExpr <- case Dhall.Parser.exprFromText mempty text of- Left err -> throwIO err- Right expr -> return expr- _ <- Dhall.Import.load actualExpr- return ())+getTests :: IO TestTree+getTests = do+ successTests <- Test.Util.discover (Turtle.chars <> "A.dhall") successTest (Turtle.lstree (importDirectory </> "success")) -shouldNotFailRelative :: Text -> FilePath -> FilePath -> TestTree-shouldNotFailRelative name dir path = Test.Tasty.HUnit.testCase (Data.Text.unpack name) (do- text <- Data.Text.IO.readFile path- expr <- case Dhall.Parser.exprFromText mempty text of- Left err -> throwIO err- Right expr -> return expr+ failureTests <- Test.Util.discover (Turtle.chars <> ".dhall") failureTest (Turtle.lstree (importDirectory </> "failure")) - _ <- State.evalStateT (Dhall.Import.loadWith expr) (Dhall.Import.emptyStatus dir)+ let testTree =+ Tasty.testGroup "import tests"+ [ successTests+ , failureTests+ ] - return ())+ return testTree -shouldFail :: Int -> Text -> FilePath -> TestTree-shouldFail failures name path = Test.Tasty.HUnit.testCase (Data.Text.unpack name) (do- text <- Data.Text.IO.readFile path- actualExpr <- case Dhall.Parser.exprFromText mempty text of- Left err -> throwIO err- Right expr -> return expr- catch- (do- _ <- Dhall.Import.load actualExpr- fail "Import should have failed, but it succeeds")- (\(SourcedException _ (MissingImports es)) ->- case length es == failures of- True -> pure ()- False -> fail- ( "Should have failed "- <> show failures- <> " times, but failed with: \n"- <> show es- )- ) )+successTest :: Text -> TestTree+successTest path = do+ let pathString = Text.unpack path++ let directoryString = FilePath.takeDirectory pathString++ Tasty.HUnit.testCase pathString (do++ text <- Text.IO.readFile pathString++ actualExpr <- Core.throws (Parser.exprFromText mempty text)++ _ <- State.evalStateT (Import.loadWith actualExpr) (Import.emptyStatus directoryString)++ return () )++failureTest :: Text -> TestTree+failureTest path = do+ let pathString = Text.unpack path++ Tasty.HUnit.testCase pathString (do+ text <- Text.IO.readFile pathString++ actualExpr <- Core.throws (Parser.exprFromText mempty text)++ catch+ (do _ <- Import.load actualExpr++ fail "Import should have failed, but it succeeds")+ (\(SourcedException _ (MissingImports _)) -> pure ()) )
@@ -4,58 +4,54 @@ import Data.Monoid (mempty, (<>)) import Data.Text (Text)+import Prelude hiding (FilePath) import Test.Tasty (TestTree)+import Turtle (FilePath) -import qualified Control.Exception-import qualified Data.Text-import qualified Data.Text.IO-import qualified Dhall.Core-import qualified Dhall.Import-import qualified Dhall.Lint-import qualified Dhall.Parser-import qualified Test.Tasty-import qualified Test.Tasty.HUnit+import qualified Data.Text as Text+import qualified Data.Text.IO as Text.IO+import qualified Dhall.Core as Core+import qualified Dhall.Import as Import+import qualified Dhall.Lint as Lint+import qualified Dhall.Parser as Parser+import qualified Dhall.Test.Util as Test.Util+import qualified Test.Tasty as Tasty+import qualified Test.Tasty.HUnit as Tasty.HUnit+import qualified Turtle -tests :: TestTree-tests =- Test.Tasty.testGroup "format tests"- [ should- "correctly handle multi-let expressions"- "success/multilet"- , should- "not fail when an inner expression removes all `let` bindings"- "success/regression0"- ]+lintDirectory :: FilePath+lintDirectory = "./tests/lint" -should :: Text -> Text -> TestTree-should name basename =- Test.Tasty.HUnit.testCase (Data.Text.unpack name) $ do- let inputFile =- Data.Text.unpack ("./tests/lint/" <> basename <> "A.dhall")- let outputFile =- Data.Text.unpack ("./tests/lint/" <> basename <> "B.dhall")+getTests :: IO TestTree+getTests = do+ formatTests <- Test.Util.discover (Turtle.chars <* "A.dhall") lintTest (Turtle.lstree lintDirectory) - inputText <- Data.Text.IO.readFile inputFile+ let testTree = Tasty.testGroup "format tests" [ formatTests ] - parsedInput <- case Dhall.Parser.exprFromText mempty inputText of- Left exception -> Control.Exception.throwIO exception- Right expression -> return expression+ return testTree - let lintedInput = Dhall.Lint.lint parsedInput+lintTest :: Text -> TestTree+lintTest prefix =+ Tasty.HUnit.testCase (Text.unpack prefix) $ do+ let inputFile = Text.unpack (prefix <> "A.dhall")+ let outputFile = Text.unpack (prefix <> "B.dhall") - actualExpression <- Dhall.Import.load lintedInput+ inputText <- Text.IO.readFile inputFile - outputText <- Data.Text.IO.readFile outputFile+ parsedInput <- Core.throws (Parser.exprFromText mempty inputText) - parsedOutput <- case Dhall.Parser.exprFromText mempty outputText of- Left exception -> Control.Exception.throwIO exception- Right expression -> return expression+ let lintedInput = Lint.lint parsedInput - resolvedOutput <- Dhall.Import.load parsedOutput+ actualExpression <- Import.load lintedInput - let expectedExpression = Dhall.Core.denote resolvedOutput+ outputText <- Text.IO.readFile outputFile - let message =- "The linted expression did not match the expected output"+ parsedOutput <- Core.throws (Parser.exprFromText mempty outputText) - Test.Tasty.HUnit.assertEqual message expectedExpression actualExpression+ resolvedOutput <- Import.load parsedOutput++ let expectedExpression = Core.denote resolvedOutput++ let message = "The linted expression did not match the expected output"++ Tasty.HUnit.assertEqual message expectedExpression actualExpression
@@ -1,6 +1,7 @@ module Main where -import Test.Tasty (TestTree)+import System.FilePath ((</>))+import Test.Tasty (TestTree) import qualified Dhall.Test.Dhall import qualified Dhall.Test.Format@@ -18,27 +19,44 @@ import qualified System.IO import qualified Test.Tasty -import System.FilePath ((</>))+getAllTests :: IO TestTree+getAllTests = do+ normalizationTests <- Dhall.Test.Normalization.getTests -allTests :: TestTree-allTests =- Test.Tasty.testGroup "Dhall Tests"- [ Dhall.Test.Normalization.tests- , Dhall.Test.Parser.tests- , Dhall.Test.Regression.tests- , Dhall.Test.Tutorial.tests- , Dhall.Test.Format.tests- , Dhall.Test.TypeCheck.tests- , Dhall.Test.Import.tests- , Dhall.Test.QuickCheck.tests- , Dhall.Test.Lint.tests- , Dhall.Test.Dhall.tests- ]+ parsingTests <- Dhall.Test.Parser.getTests + formattingTests <- Dhall.Test.Format.getTests++ typecheckingTests <- Dhall.Test.TypeCheck.getTests++ importingTests <- Dhall.Test.Import.getTests++ lintTests <- Dhall.Test.Lint.getTests++ let testTree =+ Test.Tasty.testGroup "Dhall Tests"+ [ normalizationTests+ , parsingTests+ , importingTests+ , typecheckingTests+ , formattingTests+ , lintTests+ , Dhall.Test.Regression.tests+ , Dhall.Test.Tutorial.tests+ , Dhall.Test.QuickCheck.tests+ , Dhall.Test.Dhall.tests+ ]++ return testTree+ main :: IO () main = do- GHC.IO.Encoding.setLocaleEncoding System.IO.utf8+ pwd <- System.Directory.getCurrentDirectory+ System.Environment.setEnv "XDG_CACHE_HOME" (pwd </> ".cache")++ allTests <- getAllTests+ Test.Tasty.defaultMain allTests
@@ -1,312 +1,216 @@-{-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-} module Dhall.Test.Normalization where import Data.Monoid ((<>)) import Data.Text (Text)-import Dhall.Core (Expr)+import Dhall.Core (Expr(..), Var(..), throws) import Dhall.TypeCheck (X)+import Prelude hiding (FilePath)+import Test.Tasty (TestTree)+import Turtle (FilePath, (</>)) -import qualified Control.Exception-import qualified Data.Text-import qualified Dhall.Core-import qualified Dhall.Import-import qualified Dhall.Parser-import qualified Dhall.TypeCheck+import qualified Control.Monad as Monad+import qualified Data.Text as Text+import qualified Data.Text.IO as Text.IO+import qualified Dhall.Context as Context+import qualified Dhall.Core as Core+import qualified Dhall.Import as Import+import qualified Dhall.Parser as Parser+import qualified Dhall.Test.Util as Test.Util+import qualified Dhall.TypeCheck as TypeCheck+import qualified Test.Tasty as Tasty+import qualified Test.Tasty.HUnit as Tasty.HUnit+import qualified Turtle -import Dhall.Core-import Dhall.Context-import Test.Tasty-import Test.Tasty.HUnit-import Dhall.Test.Util+normalizationDirectory :: FilePath+normalizationDirectory = "./dhall-lang/tests/normalization/success" -tests :: TestTree-tests =- testGroup "normalization"- [ tutorialExamples- , preludeExamples- , simplifications- , constantFolding- , conversions- , customization- , shouldNormalize- "Optional build/fold fusion"- "success/simple/optionalBuildFold"- , shouldNormalize- "a remote-systems.conf builder"- "success/remoteSystems"- , shouldNormalize- "multi-line strings correctly"- "success/simple/multiLine"- , shouldNormalize- "the // operator and sort the fields"- "success/simple/sortOperator"- , multiline- ]+getTests :: IO TestTree+getTests = do+ let pattern = Turtle.chars <* "A.dhall" -tutorialExamples :: TestTree-tutorialExamples =- testGroup "Tutorial examples"- [ shouldNormalize "⩓" "./success/haskell-tutorial/combineTypes/0"- , shouldNormalize "//\\\\" "./success/haskell-tutorial/combineTypes/1"- , shouldNormalize "//" "./success/haskell-tutorial/prefer/0"- , shouldNormalize "projection" "./success/haskell-tutorial/projection/0"- , shouldNormalize "access record" "./success/haskell-tutorial/access/0"- , shouldNormalize "access union" "./success/haskell-tutorial/access/1"- ]+ let normalizationFiles = do+ path <- Turtle.lstree normalizationDirectory -preludeExamples :: TestTree-preludeExamples =- testGroup "Prelude examples"- [ shouldNormalize "Bool/and" "./success/prelude/Bool/and/0"- , shouldNormalize "Bool/and" "./success/prelude/Bool/and/1"- , shouldNormalize "Bool/build" "./success/prelude/Bool/build/0"- , shouldNormalize "Bool/build" "./success/prelude/Bool/build/1"- , shouldNormalize "Bool/even" "./success/prelude/Bool/even/0"- , shouldNormalize "Bool/even" "./success/prelude/Bool/even/1"- , shouldNormalize "Bool/even" "./success/prelude/Bool/even/2"- , shouldNormalize "Bool/even" "./success/prelude/Bool/even/3"- , shouldNormalize "Bool/fold" "./success/prelude/Bool/fold/0"- , shouldNormalize "Bool/fold" "./success/prelude/Bool/fold/1"- , shouldNormalize "Bool/not" "./success/prelude/Bool/not/0"- , shouldNormalize "Bool/not" "./success/prelude/Bool/not/1"- , shouldNormalize "Bool/odd" "./success/prelude/Bool/odd/0"- , shouldNormalize "Bool/odd" "./success/prelude/Bool/odd/1"- , shouldNormalize "Bool/odd" "./success/prelude/Bool/odd/2"- , shouldNormalize "Bool/odd" "./success/prelude/Bool/odd/3"- , shouldNormalize "Bool/or" "./success/prelude/Bool/or/0"- , shouldNormalize "Bool/or" "./success/prelude/Bool/or/1"- , shouldNormalize "Bool/show" "./success/prelude/Bool/show/0"- , shouldNormalize "Bool/show" "./success/prelude/Bool/show/1"- , shouldNormalize "Double/show" "./success/prelude/Double/show/0"- , shouldNormalize "Double/show" "./success/prelude/Double/show/1"- , shouldNormalize "Integer/show" "./success/prelude/Integer/show/0"- , shouldNormalize "Integer/show" "./success/prelude/Integer/show/1"- , shouldNormalize "Integer/toDouble" "./success/prelude/Integer/toDouble/0"- , shouldNormalize "Integer/toDouble" "./success/prelude/Integer/toDouble/1"- , shouldNormalize "List/all" "./success/prelude/List/all/0"- , shouldNormalize "List/all" "./success/prelude/List/all/1"- , shouldNormalize "List/any" "./success/prelude/List/any/0"- , shouldNormalize "List/any" "./success/prelude/List/any/1"- , shouldNormalize "List/build" "./success/prelude/List/build/0"- , shouldNormalize "List/build" "./success/prelude/List/build/1"- , shouldNormalize "List/concat" "./success/prelude/List/concat/0"- , shouldNormalize "List/concat" "./success/prelude/List/concat/1"- , shouldNormalize "List/concatMap" "./success/prelude/List/concatMap/0"- , shouldNormalize "List/concatMap" "./success/prelude/List/concatMap/1"- , shouldNormalize "List/filter" "./success/prelude/List/filter/0"- , shouldNormalize "List/filter" "./success/prelude/List/filter/1"- , shouldNormalize "List/fold" "./success/prelude/List/fold/0"- , shouldNormalize "List/fold" "./success/prelude/List/fold/1"- , shouldNormalize "List/fold" "./success/prelude/List/fold/2"- , shouldNormalize "List/generate" "./success/prelude/List/generate/0"- , shouldNormalize "List/generate" "./success/prelude/List/generate/1"- , shouldNormalize "List/head" "./success/prelude/List/head/0"- , shouldNormalize "List/head" "./success/prelude/List/head/1"- , shouldNormalize "List/indexed" "./success/prelude/List/indexed/0"- , shouldNormalize "List/indexed" "./success/prelude/List/indexed/1"- , shouldNormalize "List/iterate" "./success/prelude/List/iterate/0"- , shouldNormalize "List/iterate" "./success/prelude/List/iterate/1"- , shouldNormalize "List/last" "./success/prelude/List/last/0"- , shouldNormalize "List/last" "./success/prelude/List/last/1"- , shouldNormalize "List/length" "./success/prelude/List/length/0"- , shouldNormalize "List/length" "./success/prelude/List/length/1"- , shouldNormalize "List/map" "./success/prelude/List/map/0"- , shouldNormalize "List/map" "./success/prelude/List/map/1"- , shouldNormalize "List/null" "./success/prelude/List/null/0"- , shouldNormalize "List/null" "./success/prelude/List/null/1"- , shouldNormalize "List/replicate" "./success/prelude/List/replicate/0"- , shouldNormalize "List/replicate" "./success/prelude/List/replicate/1"- , shouldNormalize "List/reverse" "./success/prelude/List/reverse/0"- , shouldNormalize "List/reverse" "./success/prelude/List/reverse/1"- , shouldNormalize "List/shifted" "./success/prelude/List/shifted/0"- , shouldNormalize "List/shifted" "./success/prelude/List/shifted/1"- , shouldNormalize "List/unzip" "./success/prelude/List/unzip/0"- , shouldNormalize "List/unzip" "./success/prelude/List/unzip/1"- , shouldNormalize "Natural/build" "./success/prelude/Natural/build/0"- , shouldNormalize "Natural/build" "./success/prelude/Natural/build/1"- , shouldNormalize "Natural/enumerate" "./success/prelude/Natural/enumerate/0"- , shouldNormalize "Natural/enumerate" "./success/prelude/Natural/enumerate/1"- , shouldNormalize "Natural/even" "./success/prelude/Natural/even/0"- , shouldNormalize "Natural/even" "./success/prelude/Natural/even/1"- , shouldNormalize "Natural/fold" "./success/prelude/Natural/fold/0"- , shouldNormalize "Natural/fold" "./success/prelude/Natural/fold/1"- , shouldNormalize "Natural/fold" "./success/prelude/Natural/fold/2"- , shouldNormalize "Natural/isZero" "./success/prelude/Natural/isZero/0"- , shouldNormalize "Natural/isZero" "./success/prelude/Natural/isZero/1"- , shouldNormalize "Natural/odd" "./success/prelude/Natural/odd/0"- , shouldNormalize "Natural/odd" "./success/prelude/Natural/odd/1"- , shouldNormalize "Natural/product" "./success/prelude/Natural/product/0"- , shouldNormalize "Natural/product" "./success/prelude/Natural/product/1"- , shouldNormalize "Natural/show" "./success/prelude/Natural/show/0"- , shouldNormalize "Natural/show" "./success/prelude/Natural/show/1"- , shouldNormalize "Natural/sum" "./success/prelude/Natural/sum/0"- , shouldNormalize "Natural/sum" "./success/prelude/Natural/sum/1"- , shouldNormalize "Natural/toDouble" "./success/prelude/Natural/toDouble/0"- , shouldNormalize "Natural/toDouble" "./success/prelude/Natural/toDouble/1"- , shouldNormalize "Natural/toInteger" "./success/prelude/Natural/toInteger/0"- , shouldNormalize "Natural/toInteger" "./success/prelude/Natural/toInteger/1"- , shouldNormalize "Optional/all" "./success/prelude/Optional/all/0"- , shouldNormalize "Optional/all" "./success/prelude/Optional/all/1"- , shouldNormalize "Optional/any" "./success/prelude/Optional/any/0"- , shouldNormalize "Optional/any" "./success/prelude/Optional/any/1"- , shouldNormalize "Optional/build" "./success/prelude/Optional/build/0"- , shouldNormalize "Optional/build" "./success/prelude/Optional/build/1"- , shouldNormalize "Optional/concat" "./success/prelude/Optional/concat/0"- , shouldNormalize "Optional/concat" "./success/prelude/Optional/concat/1"- , shouldNormalize "Optional/concat" "./success/prelude/Optional/concat/2"- , shouldNormalize "Optional/filter" "./success/prelude/Optional/filter/0"- , shouldNormalize "Optional/filter" "./success/prelude/Optional/filter/1"- , shouldNormalize "Optional/fold" "./success/prelude/Optional/fold/0"- , shouldNormalize "Optional/fold" "./success/prelude/Optional/fold/1"- , shouldNormalize "Optional/head" "./success/prelude/Optional/head/0"- , shouldNormalize "Optional/head" "./success/prelude/Optional/head/1"- , shouldNormalize "Optional/head" "./success/prelude/Optional/head/2"- , shouldNormalize "Optional/last" "./success/prelude/Optional/last/0"- , shouldNormalize "Optional/last" "./success/prelude/Optional/last/1"- , shouldNormalize "Optional/last" "./success/prelude/Optional/last/2"- , shouldNormalize "Optional/length" "./success/prelude/Optional/length/0"- , shouldNormalize "Optional/length" "./success/prelude/Optional/length/1"- , shouldNormalize "Optional/map" "./success/prelude/Optional/map/0"- , shouldNormalize "Optional/map" "./success/prelude/Optional/map/1"- , shouldNormalize "Optional/null" "./success/prelude/Optional/null/0"- , shouldNormalize "Optional/null" "./success/prelude/Optional/null/1"- , shouldNormalize "Optional/toList" "./success/prelude/Optional/toList/0"- , shouldNormalize "Optional/toList" "./success/prelude/Optional/toList/1"- , shouldNormalize "Optional/unzip" "./success/prelude/Optional/unzip/0"- , shouldNormalize "Optional/unzip" "./success/prelude/Optional/unzip/1"- , shouldNormalize "Text/concat" "./success/prelude/Text/concat/0"- , shouldNormalize "Text/concat" "./success/prelude/Text/concat/1"- , shouldNormalize "Text/concatMap" "./success/prelude/Text/concatMap/0"- , shouldNormalize "Text/concatMap" "./success/prelude/Text/concatMap/1"- , shouldNormalize "Text/concatMapSep" "./success/prelude/Text/concatMapSep/0"- , shouldNormalize "Text/concatMapSep" "./success/prelude/Text/concatMapSep/1"- , shouldNormalize "Text/concatSep" "./success/prelude/Text/concatSep/0"- , shouldNormalize "Text/concatSep" "./success/prelude/Text/concatSep/1"- , shouldNormalize "Text/show" "./success/prelude/Text/show/0"- , shouldNormalize "Text/show" "./success/prelude/Text/show/1"- ]+ Nothing <- return (Turtle.stripPrefix (normalizationDirectory </> "unit/") path) -simplifications :: TestTree-simplifications =- testGroup "Simplifications"- [ shouldNormalize "if/then/else" "./success/simplifications/ifThenElse"- , shouldNormalize "||" "./success/simplifications/or"- , shouldNormalize "&&" "./success/simplifications/and"- , shouldNormalize "==" "./success/simplifications/eq"- , shouldNormalize "!=" "./success/simplifications/ne"- ]+ return path -constantFolding :: TestTree-constantFolding =- testGroup "folding of constants"- [ shouldNormalize "Natural/plus" "success/simple/naturalPlus"- , shouldNormalize "Optional/fold" "success/simple/optionalFold"- , shouldNormalize "Optional/build" "success/simple/optionalBuild"- , shouldNormalize "Natural/build" "success/simple/naturalBuild"- ]+ betaNormalizationTests <- Test.Util.discover pattern betaNormalizationTest normalizationFiles -conversions :: TestTree-conversions =- testGroup "conversions"- [ shouldNormalize "Natural/show" "success/simple/naturalShow"- , shouldNormalize "Integer/show" "success/simple/integerShow"- , shouldNormalize "Double/show" "success/simple/doubleShow"- , shouldNormalize "Natural/toInteger" "success/simple/naturalToInteger"- , shouldNormalize "Integer/toDouble" "success/simple/integerToDouble"- ]+ alphaNormalizationTests <- do+ Test.Util.discover pattern alphaNormalizationTest+ -- Hackage rejects packages with Unicode directory names. This+ -- will be fixed in the next release of `dhall` but for now we+ -- disable the tests that depend on the `α-normalization` directory+ -- (Turtle.lstree "./dhall-lang/tests/α-normalization/success/")+ Turtle.empty + let unitTestFiles = do+ path <- Turtle.lstree "./dhall-lang/tests/normalization/success/unit"++ let skip =+ [ normalizationDirectory </> "unit/EmptyAlternativeA.dhall"+ -- https://github.com/dhall-lang/dhall-lang/issues/505+ , normalizationDirectory </> "unit/OperatorTextConcatenateLhsEmptyA.dhall"+ ]++ Monad.guard (path `notElem` skip)++ return path++ unitTests <- Test.Util.discover pattern unitTest unitTestFiles++ let testTree =+ Tasty.testGroup "normalization"+ [ betaNormalizationTests+ , unitTests+ , alphaNormalizationTests+ , customization+ ]++ return testTree+ customization :: TestTree customization =- testGroup "customization"+ Tasty.testGroup "customization" [ simpleCustomization , nestedReduction ] -multiline :: TestTree-multiline =- testGroup "Multi-line literals"- [ shouldNormalize- "multi-line escape sequences"- "./success/multiline/escape"- , shouldNormalize- "a multi-line literal with a hanging indent"- "./success/multiline/hangingIndent"- , shouldNormalize- "a multi-line literal with an interior indent"- "./success/multiline/interiorIndent"- , shouldNormalize- "a multi-line literal with an interpolated expression"- "./success/multiline/interpolation"- , should- "preserve comments within a multi-line literal"- "./success/multiline/preserveComment"- , shouldNormalize- "a multi-line literal with one line"- "./success/multiline/singleLine"- , shouldNormalize- "a multi-line literal with two lines"- "./success/multiline/twoLines"- ]- simpleCustomization :: TestTree-simpleCustomization = testCase "simpleCustomization" $ do- let tyCtx = insert "min" (Pi "_" Natural (Pi "_" Natural Natural)) empty- valCtx e = case e of- (App (App (Var (V "min" 0)) (NaturalLit x)) (NaturalLit y)) -> pure (Just (NaturalLit (min x y)))- _ -> pure Nothing- e <- codeWith tyCtx "min (min 11 12) 8 + 1"- assertNormalizesToWith valCtx e "9"+simpleCustomization = Tasty.HUnit.testCase "simpleCustomization" $ do+ let tyCtx =+ Context.insert+ "min"+ (Pi "_" Natural (Pi "_" Natural Natural))+ Context.empty + valCtx e =+ case e of+ App (App (Var (V "min" 0)) (NaturalLit x)) (NaturalLit y) ->+ pure (Just (NaturalLit (min x y)))+ _ ->+ pure Nothing++ e <- Test.Util.codeWith tyCtx "min (min 11 12) 8 + 1"++ Test.Util.assertNormalizesToWith valCtx e "9"+ nestedReduction :: TestTree-nestedReduction = testCase "doubleReduction" $ do- minType <- insert "min" <$> code "Natural → Natural → Natural"- fiveorlessType <- insert "fiveorless" <$> code "Natural → Natural"- wurbleType <- insert "wurble" <$> code "Natural → Integer"- let tyCtx = minType . fiveorlessType . wurbleType $ empty- valCtx e = case e of- (App (App (Var (V "min" 0)) (NaturalLit x)) (NaturalLit y)) -> pure (Just (NaturalLit (min x y)))- (App (Var (V "wurble" 0)) (NaturalLit x)) -> pure (Just- (App (Var (V "fiveorless" 0)) (NaturalPlus (NaturalLit x) (NaturalLit 2))))- (App (Var (V "fiveorless" 0)) (NaturalLit x)) -> pure (Just- (App (App (Var (V "min" 0)) (NaturalLit x)) (NaturalPlus (NaturalLit 3) (NaturalLit 2))))- _ -> pure Nothing- e <- codeWith tyCtx "wurble 6"- assertNormalizesToWith valCtx e "5"+nestedReduction = Tasty.HUnit.testCase "doubleReduction" $ do+ minType <- Context.insert "min" <$> Test.Util.code "Natural → Natural → Natural"+ fiveorlessType <- Context.insert "fiveorless" <$> Test.Util.code "Natural → Natural"+ wurbleType <- Context.insert "wurble" <$> Test.Util.code "Natural → Integer" -should :: Text -> Text -> TestTree-should name basename =- Test.Tasty.HUnit.testCase (Data.Text.unpack name) $ do- let actualCode = "./dhall-lang/tests/normalization/" <> basename <> "A.dhall"- let expectedCode = "./dhall-lang/tests/normalization/" <> basename <> "B.dhall"+ let tyCtx = minType . fiveorlessType . wurbleType $ Context.empty - actualExpr <- case Dhall.Parser.exprFromText mempty actualCode of- Left err -> Control.Exception.throwIO err- Right expr -> return expr- actualResolved <- Dhall.Import.load actualExpr- case Dhall.TypeCheck.typeOf actualResolved of- Left err -> Control.Exception.throwIO err- Right _ -> return ()+ valCtx e =+ case e of+ App (App (Var (V "min" 0)) (NaturalLit x)) (NaturalLit y) ->+ pure (Just (NaturalLit (min x y)))+ App (Var (V "wurble" 0)) (NaturalLit x) ->+ pure (Just (App (Var (V "fiveorless" 0)) (NaturalPlus (NaturalLit x) (NaturalLit 2))))+ App (Var (V "fiveorless" 0)) (NaturalLit x) ->+ pure (Just (App (App (Var (V "min" 0)) (NaturalLit x)) (NaturalPlus (NaturalLit 3) (NaturalLit 2))))+ _ ->+ pure Nothing++ e <- Test.Util.codeWith tyCtx "wurble 6"++ Test.Util.assertNormalizesToWith valCtx e "5"++alphaNormalizationTest :: Text -> TestTree+alphaNormalizationTest prefix = do+ let prefixString = Text.unpack prefix++ Tasty.HUnit.testCase prefixString $ do+ let actualPath = prefixString <> "A.dhall"+ let expectedPath = prefixString <> "B.dhall"++ actualCode <- Text.IO.readFile actualPath+ expectedCode <- Text.IO.readFile expectedPath++ actualExpr <- throws (Parser.exprFromText mempty actualCode)++ actualResolved <- Import.assertNoImports actualExpr++ let actualNormalized = Core.alphaNormalize (Core.denote actualResolved)++ expectedExpr <- throws (Parser.exprFromText mempty expectedCode)++ expectedResolved <- Import.assertNoImports expectedExpr++ let expectedNormalized = Core.denote expectedResolved :: Expr X X++ let message =+ "The normalized expression did not match the expected output"++ Tasty.HUnit.assertEqual message expectedNormalized actualNormalized++{- Unit tests don't type-check, so we only verify that they normalize to the+ expected output+-}+unitTest :: Text -> TestTree+unitTest prefix = do+ let prefixString = Text.unpack prefix++ Tasty.HUnit.testCase prefixString $ do+ let actualPath = prefixString <> "A.dhall"+ let expectedPath = prefixString <> "B.dhall"++ actualCode <- Text.IO.readFile actualPath+ expectedCode <- Text.IO.readFile expectedPath++ actualExpr <- throws (Parser.exprFromText mempty actualCode)++ actualResolved <- Import.assertNoImports actualExpr+ let actualNormalized =- Dhall.Core.alphaNormalize- (Dhall.Core.normalize actualResolved :: Expr X X)+ Core.alphaNormalize+ (Core.normalize actualResolved :: Expr X X) - expectedExpr <- case Dhall.Parser.exprFromText mempty expectedCode of- Left err -> Control.Exception.throwIO err- Right expr -> return expr- expectedResolved <- Dhall.Import.load expectedExpr- case Dhall.TypeCheck.typeOf expectedResolved of- Left err -> Control.Exception.throwIO err- Right _ -> return ()+ expectedExpr <- throws (Parser.exprFromText mempty expectedCode)++ expectedResolved <- Import.assertNoImports expectedExpr++ let expectedNormalized =+ Core.alphaNormalize (Core.denote expectedResolved)++ let message =+ "The normalized expression did not match the expected output"++ Tasty.HUnit.assertEqual message expectedNormalized actualNormalized++betaNormalizationTest :: Text -> TestTree+betaNormalizationTest prefix =+ Tasty.HUnit.testCase (Text.unpack prefix) $ do+ let actualCode = Test.Util.toDhallPath (prefix <> "A.dhall")+ let expectedCode = Test.Util.toDhallPath (prefix <> "B.dhall")++ actualExpr <- throws (Parser.exprFromText mempty actualCode)++ actualResolved <- Import.load actualExpr++ _ <- throws (TypeCheck.typeOf actualResolved)++ let actualNormalized =+ Core.alphaNormalize+ (Core.normalize actualResolved :: Expr X X)++ expectedExpr <- throws (Parser.exprFromText mempty expectedCode)++ expectedResolved <- Import.load expectedExpr++ _ <- throws (TypeCheck.typeOf expectedResolved)+ -- Use `denote` instead of `normalize` to enforce that the expected -- expression is already in normal form let expectedNormalized =- Dhall.Core.alphaNormalize (Dhall.Core.denote expectedResolved)+ Core.alphaNormalize (Core.denote expectedResolved) let message = "The normalized expression did not match the expected output"- Test.Tasty.HUnit.assertEqual message expectedNormalized actualNormalized -shouldNormalize :: Text -> Text -> TestTree-shouldNormalize name = should ("normalize " <> name <> " correctly")+ Tasty.HUnit.assertEqual message expectedNormalized actualNormalized
@@ -2,191 +2,80 @@ module Dhall.Test.Parser where -import Data.Text (Text)-import Test.Tasty (TestTree)+import Data.Text (Text)+import Prelude hiding (FilePath)+import Test.Tasty (TestTree)+import Turtle (FilePath, (</>)) -import qualified Codec.Serialise-import qualified Control.Exception-import qualified Data.ByteString.Lazy-import qualified Data.Text-import qualified Data.Text.IO-import qualified Dhall.Binary-import qualified Dhall.Parser-import qualified Test.Tasty-import qualified Test.Tasty.HUnit+import qualified Codec.Serialise as Serialise+import qualified Control.Monad as Monad+import qualified Data.ByteString.Lazy as ByteString.Lazy+import qualified Data.Text as Text+import qualified Data.Text.IO as Text.IO+import qualified Dhall.Binary as Binary+import qualified Dhall.Core as Core+import qualified Dhall.Parser as Parser+import qualified Dhall.Test.Util as Test.Util+import qualified Test.Tasty as Tasty+import qualified Test.Tasty.HUnit as Tasty.HUnit+import qualified Turtle -tests :: TestTree-tests =- Test.Tasty.testGroup "parser tests"- [ Test.Tasty.testGroup "whitespace"- [ shouldParse- "prefix/suffix"- "./dhall-lang/tests/parser/success/whitespace"- , shouldParse- "block comment"- "./dhall-lang/tests/parser/success/blockComment"- , shouldParse- "nested block comment"- "./dhall-lang/tests/parser/success/nestedBlockComment"- , shouldParse- "line comment"- "./dhall-lang/tests/parser/success/lineComment"- , shouldParse- "Unicode comment"- "./dhall-lang/tests/parser/success/unicodeComment"- , shouldParse- "whitespace buffet"- "./dhall-lang/tests/parser/success/whitespaceBuffet"- ]- , shouldParse- "label"- "./dhall-lang/tests/parser/success/label"- , shouldParse- "quoted label"- "./dhall-lang/tests/parser/success/quotedLabel"- , shouldParse- "double quoted string"- "./dhall-lang/tests/parser/success/doubleQuotedString"- , shouldParse- "Unicode double quoted string"- "./dhall-lang/tests/parser/success/unicodeDoubleQuotedString"- , shouldParse- "escaped double quoted string"- "./dhall-lang/tests/parser/success/escapedDoubleQuotedString"- , shouldParse- "interpolated double quoted string"- "./dhall-lang/tests/parser/success/interpolatedDoubleQuotedString"- , shouldParse- "single quoted string"- "./dhall-lang/tests/parser/success/singleQuotedString"- , shouldParse- "escaped single quoted string"- "./dhall-lang/tests/parser/success/escapedSingleQuotedString"- , shouldParse- "interpolated single quoted string"- "./dhall-lang/tests/parser/success/interpolatedSingleQuotedString"- , shouldParse- "double"- "./dhall-lang/tests/parser/success/double"- , shouldParse- "natural"- "./dhall-lang/tests/parser/success/natural"- , shouldParse- "identifier"- "./dhall-lang/tests/parser/success/identifier"- , shouldParse- "paths"- "./dhall-lang/tests/parser/success/paths"- , shouldParse- "path termination"- "./dhall-lang/tests/parser/success/pathTermination"- , shouldParse- "urls"- "./dhall-lang/tests/parser/success/urls"- , shouldParse- "environmentVariables"- "./dhall-lang/tests/parser/success/environmentVariables"- , shouldParse- "lambda"- "./dhall-lang/tests/parser/success/lambda"- , shouldParse- "if then else"- "./dhall-lang/tests/parser/success/ifThenElse"- , shouldParse- "let"- "./dhall-lang/tests/parser/success/let"- , shouldParse- "forall"- "./dhall-lang/tests/parser/success/forall"- , shouldParse- "function type"- "./dhall-lang/tests/parser/success/functionType"- , shouldParse- "operators"- "./dhall-lang/tests/parser/success/operators"- , shouldParse- "annotations"- "./dhall-lang/tests/parser/success/annotations"- , shouldParse- "merge"- "./dhall-lang/tests/parser/success/merge"- , shouldParse- "fields"- "./dhall-lang/tests/parser/success/fields"- , shouldParse- "record"- "./dhall-lang/tests/parser/success/record"- , shouldParse- "union"- "./dhall-lang/tests/parser/success/union"- , shouldParse- "list"- "./dhall-lang/tests/parser/success/list"- , shouldParse- "builtins"- "./dhall-lang/tests/parser/success/builtins"- , shouldParse- "import alternatives"- "./dhall-lang/tests/parser/success/importAlt"- , shouldParse- "large expression"- "./dhall-lang/tests/parser/success/largeExpression"- , shouldParse- "names that begin with reserved identifiers"- "./dhall-lang/tests/parser/success/reservedPrefix"- , shouldParse- "interpolated expressions with leading whitespace"- "./dhall-lang/tests/parser/success/template"- , shouldParse- "collections with type annotations containing imports"- "./dhall-lang/tests/parser/success/collectionImportType"- , shouldParse- "a parenthesized custom header import"- "./dhall-lang/tests/parser/success/parenthesizeUsing"- , shouldNotParse- "accessing a field of an import without parentheses"- "./dhall-lang/tests/parser/failure/importAccess.dhall"- , shouldParse- "Sort"- "./dhall-lang/tests/parser/success/sort"- , shouldParse- "quoted path components"- "./dhall-lang/tests/parser/success/quotedPaths"- , shouldNotParse- "positive double out of bounds"- "./dhall-lang/tests/parser/failure/doubleBoundsPos.dhall"- , shouldNotParse- "negative double out of bounds"- "./dhall-lang/tests/parser/failure/doubleBoundsNeg.dhall"- , shouldParse- "as Text"- "./dhall-lang/tests/parser/success/asText"- , shouldNotParse- "a multi-line literal without an initial newline"- "./dhall-lang/tests/parser/failure/mandatoryNewline.dhall"- , shouldParse- "a Unicode path component"- "./dhall-lang/tests/parser/success/unicodePaths"- ]+parseDirectory :: FilePath+parseDirectory = "./dhall-lang/tests/parser" -shouldParse :: Text -> FilePath -> TestTree-shouldParse name path = Test.Tasty.HUnit.testCase (Data.Text.unpack name) $ do- text <- Data.Text.IO.readFile (path <> "A.dhall")- encoded <- Data.ByteString.Lazy.readFile (path <> "B.dhallb")+getTests :: IO TestTree+getTests = do+ successTests <- do+ Test.Util.discover (Turtle.chars <* "A.dhall") shouldParse (Turtle.lstree (parseDirectory </> "success")) - expression <- case Dhall.Parser.exprFromText mempty text of- Left e -> Control.Exception.throwIO e- Right a -> pure a+ let failureFiles = do+ path <- Turtle.lstree (parseDirectory </> "failure") - let term = Dhall.Binary.encode expression- bytes = Codec.Serialise.serialise term+ let skip =+ [ parseDirectory </> "failure/annotation.dhall"+ , parseDirectory </> "failure/missingSpace.dhall"+ ] - let message = "The expected CBOR representation doesn't match the actual one"- Test.Tasty.HUnit.assertEqual message encoded bytes+ Monad.guard (path `notElem` skip) -shouldNotParse :: Text -> FilePath -> TestTree-shouldNotParse name path = Test.Tasty.HUnit.testCase (Data.Text.unpack name) (do- text <- Data.Text.IO.readFile path- case Dhall.Parser.exprFromText mempty text of- Left _ -> return ()- Right _ -> fail "Unexpected successful parser" )+ return path++ failureTests <- do+ Test.Util.discover (Turtle.chars <> ".dhall") shouldNotParse failureFiles++ let testTree =+ Tasty.testGroup "parser tests"+ [ successTests+ , failureTests+ ]++ return testTree++shouldParse :: Text -> TestTree+shouldParse path = do+ let pathString = Text.unpack path++ Tasty.HUnit.testCase pathString $ do+ text <- Text.IO.readFile (pathString <> "A.dhall")++ encoded <- ByteString.Lazy.readFile (pathString <> "B.dhallb")++ expression <- Core.throws (Parser.exprFromText mempty text)++ let term = Binary.encode expression++ let bytes = Serialise.serialise term++ let message = "The expected CBOR representation doesn't match the actual one"+ Tasty.HUnit.assertEqual message encoded bytes++shouldNotParse :: Text -> TestTree+shouldNotParse path = do+ let pathString = Text.unpack path++ Tasty.HUnit.testCase pathString (do+ text <- Text.IO.readFile pathString++ case Parser.exprFromText mempty text of+ Left _ -> return ()+ Right _ -> fail "Unexpected successful parser" )
@@ -7,7 +7,6 @@ module Dhall.Test.QuickCheck where import Codec.Serialise (DeserialiseFailure(..))-import Control.Monad (guard) import Data.Either (isRight) import Data.List.NonEmpty (NonEmpty(..)) import Dhall.Map (Map)@@ -40,7 +39,6 @@ import qualified Dhall.Map import qualified Data.Sequence import qualified Dhall.Binary-import qualified Dhall.Core import qualified Dhall.Diff import qualified Dhall.Set import qualified Dhall.TypeCheck@@ -266,39 +264,24 @@ instance Arbitrary ImportType where arbitrary =- Test.QuickCheck.suchThat- (Test.QuickCheck.oneof- [ lift2 Local- , lift5 (\a b c d e -> Remote (URL a b c d e Nothing))- , lift1 Env- , lift0 Missing- ]- )- standardizedImportType-- shrink importType =- filter standardizedImportType (genericShrink importType)+ Test.QuickCheck.oneof+ [ lift2 Local+ , lift5 (\a b c d e -> Remote (URL a b c d e))+ , lift1 Env+ , lift0 Missing+ ] -standardizedImportType :: ImportType -> Bool-standardizedImportType (Remote (URL _ _ _ _ _ (Just _))) = False-standardizedImportType _ = True+ shrink = genericShrink instance Arbitrary ImportHashed where arbitrary =- Test.QuickCheck.suchThat- (lift1 (ImportHashed Nothing))- standardizedImportHashed+ lift1 (ImportHashed Nothing) shrink (ImportHashed { importType = oldImportType, .. }) = do newImportType <- shrink oldImportType let importHashed = ImportHashed { importType = newImportType, .. }- guard (standardizedImportHashed importHashed) return importHashed -standardizedImportHashed :: ImportHashed -> Bool-standardizedImportHashed (ImportHashed (Just _) _) = False-standardizedImportHashed _ = True- -- The standard does not yet specify how to encode `as Text`, so don't test it -- yet instance Arbitrary ImportMode where@@ -317,16 +300,16 @@ shrink = genericShrink instance Arbitrary URL where- arbitrary = lift6 URL+ arbitrary = lift5 URL shrink = genericShrink instance Arbitrary Var where arbitrary = Test.QuickCheck.oneof- [ fmap (V "_") natural+ [ fmap (V "_") (fromIntegral <$> (natural :: Gen Int)) , lift1 (\t -> V t 0)- , lift1 V <*> natural+ , lift1 V <*> (fromIntegral <$> (natural :: Gen Int)) ] shrink = genericShrink@@ -335,10 +318,10 @@ binaryRoundtrip expression = wrap (fmap- Dhall.Binary.decode+ Dhall.Binary.decodeExpression (Codec.Serialise.deserialiseOrFail (Codec.Serialise.serialise- (Dhall.Binary.encode expression)+ (Dhall.Binary.encodeExpression expression) ) ) )@@ -349,10 +332,10 @@ -> Either DeserialiseFailureWithEq a wrap = Data.Coerce.coerce -isNormalizedIsConsistentWithNormalize :: Expr () Import -> Property-isNormalizedIsConsistentWithNormalize expression =- Dhall.Core.isNormalized expression- === (Dhall.Core.normalize expression == expression)+-- isNormalizedIsConsistentWithNormalize :: Expr () Import -> Property+-- isNormalizedIsConsistentWithNormalize expression =+-- Dhall.Core.isNormalized expression+-- === (Dhall.Core.normalize expression == expression) isSameAsSelf :: Expr () Import -> Property isSameAsSelf expression =@@ -369,10 +352,10 @@ [ ( "Binary serialization should round-trip" , Test.QuickCheck.property binaryRoundtrip )- , ( "isNormalized should be consistent with normalize"- , Test.QuickCheck.property- (Test.QuickCheck.withMaxSuccess 10000 isNormalizedIsConsistentWithNormalize)- )+ -- , ( "isNormalized should be consistent with normalize"+ -- , Test.QuickCheck.property+ -- (Test.QuickCheck.withMaxSuccess 10000 isNormalizedIsConsistentWithNormalize)+ -- ) , ( "An expression should have no difference with itself" , Test.QuickCheck.property (Test.QuickCheck.withMaxSuccess 10000 isSameAsSelf)
@@ -53,12 +53,12 @@ Test.Tasty.HUnit.assertEqual "Good type" (Dhall.expected ty) (Dhall.Core.Union (Dhall.Map.fromList- [ ("Foo",Dhall.Core.Record (Dhall.Map.fromList [- ("_1",Dhall.Core.Integer),("_2",Dhall.Core.Bool)]))- , ("Bar",Dhall.Core.Record (Dhall.Map.fromList [- ("_1",Dhall.Core.Bool),("_2",Dhall.Core.Bool),("_3",Dhall.Core.Bool)]))- , ("Baz",Dhall.Core.Record (Dhall.Map.fromList [- ("_1",Dhall.Core.Integer),("_2",Dhall.Core.Integer)]))+ [ ("Foo",Just (Dhall.Core.Record (Dhall.Map.fromList [+ ("_1",Dhall.Core.Integer),("_2",Dhall.Core.Bool)])))+ , ("Bar",Just (Dhall.Core.Record (Dhall.Map.fromList [+ ("_1",Dhall.Core.Bool),("_2",Dhall.Core.Bool),("_3",Dhall.Core.Bool)])))+ , ("Baz",Just (Dhall.Core.Record (Dhall.Map.fromList [+ ("_1",Dhall.Core.Integer),("_2",Dhall.Core.Integer)]))) ] ) )
@@ -7,131 +7,84 @@ import Dhall.Import (Imported) import Dhall.Parser (Src) import Dhall.TypeCheck (TypeError, X)+import Prelude hiding (FilePath) import Test.Tasty (TestTree)+import Turtle (FilePath, (</>)) -import qualified Control.Exception-import qualified Data.Text-import qualified Dhall.Core-import qualified Dhall.Import-import qualified Dhall.Parser-import qualified Dhall.TypeCheck-import qualified Test.Tasty-import qualified Test.Tasty.HUnit+import qualified Control.Exception as Exception+import qualified Control.Monad as Monad+import qualified Data.Text as Text+import qualified Dhall.Core as Core+import qualified Dhall.Import as Import+import qualified Dhall.Parser as Parser+import qualified Dhall.Test.Util as Test.Util+import qualified Dhall.TypeCheck as TypeCheck+import qualified Test.Tasty as Tasty+import qualified Test.Tasty.HUnit as Tasty.HUnit+import qualified Turtle -tests :: TestTree-tests =- Test.Tasty.testGroup "typecheck tests"- [ preludeExamples- , accessTypeChecks- , should- "allow type-valued fields in a record"- "success/simple/fieldsAreTypes"- , should- "allow type-valued alternatives in a union"- "success/simple/alternativesAreTypes"- , should- "allow anonymous functions in types to be judgmentally equal"- "success/simple/anonymousFunctionsInTypes"- , should- "correctly handle α-equivalent merge alternatives"- "success/simple/mergeEquivalence"- , should- "allow Kind variables"- "success/simple/kindParameter"- , shouldNotTypeCheck- "combining records of terms and types"- "failure/combineMixedRecords"- , shouldNotTypeCheck- "preferring a record of types over a record of terms"- "failure/preferMixedRecords"- , should- "allow records of types of mixed kinds"- "success/recordOfTypes"- , should- "allow accessing a type from a record"- "success/accessType"- , should- "allow accessing a type from a Boehm-Berarducci-encoded record"- "success/accessEncodedType"- , shouldNotTypeCheck- "Hurkens' paradox"- "failure/hurkensParadox"- , should- "allow accessing a constructor from a type stored inside a record"- "success/simple/mixedFieldAccess"- , should- "allow a record of a record of types"- "success/recordOfRecordOfTypes"- , should- "allow a union of types of of mixed kinds"- "success/simple/unionsOfTypes"- , shouldNotTypeCheck- "Unions mixing terms and and types"- "failure/mixedUnions"- ]+typecheckDirectory :: FilePath+typecheckDirectory = "./dhall-lang/tests/typecheck" -preludeExamples :: TestTree-preludeExamples =- Test.Tasty.testGroup "Prelude examples"- [ should "Monoid" "./success/prelude/Monoid/00"- , should "Monoid" "./success/prelude/Monoid/01"- , should "Monoid" "./success/prelude/Monoid/02"- , should "Monoid" "./success/prelude/Monoid/03"- , should "Monoid" "./success/prelude/Monoid/04"- , should "Monoid" "./success/prelude/Monoid/05"- , should "Monoid" "./success/prelude/Monoid/06"- , should "Monoid" "./success/prelude/Monoid/07"- , should "Monoid" "./success/prelude/Monoid/08"- , should "Monoid" "./success/prelude/Monoid/09"- , should "Monoid" "./success/prelude/Monoid/10"- ]+getTests :: IO TestTree+getTests = do+ successTests <- Test.Util.discover (Turtle.chars <* "A.dhall") successTest (Turtle.lstree (typecheckDirectory </> "success")) -accessTypeChecks :: TestTree-accessTypeChecks =- Test.Tasty.testGroup "typecheck access"- [ should "record" "./success/simple/access/0"- , should "record" "./success/simple/access/1"- ]+ let failureTestFiles = do+ path <- Turtle.lstree (typecheckDirectory </> "failure") -should :: Text -> Text -> TestTree-should name basename =- Test.Tasty.HUnit.testCase (Data.Text.unpack name) $ do- let actualCode = "./dhall-lang/tests/typecheck/" <> basename <> "A.dhall"- let expectedCode = "./dhall-lang/tests/typecheck/" <> basename <> "B.dhall"+ let skip =+ [ typecheckDirectory </> "failure/duplicateFields.dhall"+ ] - actualExpr <- case Dhall.Parser.exprFromText mempty actualCode of- Left err -> Control.Exception.throwIO err- Right expr -> return expr- expectedExpr <- case Dhall.Parser.exprFromText mempty expectedCode of- Left err -> Control.Exception.throwIO err- Right expr -> return expr+ Monad.guard (path `notElem` skip) - let annotatedExpr = Dhall.Core.Annot actualExpr expectedExpr+ return path - resolvedExpr <- Dhall.Import.load annotatedExpr- case Dhall.TypeCheck.typeOf resolvedExpr of- Left err -> Control.Exception.throwIO err- Right _ -> return ()+ failureTests <- Test.Util.discover (Turtle.chars <> ".dhall") failureTest failureTestFiles -shouldNotTypeCheck :: Text -> Text -> TestTree-shouldNotTypeCheck name basename =- Test.Tasty.HUnit.testCase (Data.Text.unpack name) $ do- let code = "./dhall-lang/tests/typecheck/" <> basename <> ".dhall"+ let testTree = Tasty.testGroup "typecheck tests"+ [ successTests+ , failureTests+ ] - expression <- case Dhall.Parser.exprFromText mempty code of- Left exception -> Control.Exception.throwIO exception- Right expression -> return expression+ return testTree +successTest :: Text -> TestTree+successTest prefix =+ Tasty.HUnit.testCase (Text.unpack prefix) $ do+ let actualCode = Test.Util.toDhallPath (prefix <> "A.dhall")+ let expectedCode = Test.Util.toDhallPath (prefix <> "B.dhall")++ actualExpr <- Core.throws (Parser.exprFromText mempty actualCode)++ expectedExpr <- Core.throws (Parser.exprFromText mempty expectedCode)++ let annotatedExpr = Core.Annot actualExpr expectedExpr++ resolvedExpr <- Import.load annotatedExpr++ _ <- Core.throws (TypeCheck.typeOf resolvedExpr)++ return ()++failureTest :: Text -> TestTree+failureTest path = do+ Tasty.HUnit.testCase (Text.unpack path) $ do+ let dhallPath = Test.Util.toDhallPath path++ expression <- Core.throws (Parser.exprFromText mempty dhallPath)+ let io :: IO Bool io = do- _ <- Dhall.Import.load expression+ _ <- Import.load expression return True let handler :: Imported (TypeError Src X)-> IO Bool handler _ = return False - typeChecked <- Control.Exception.handle handler io+ typeChecked <- Exception.handle handler io if typeChecked- then fail (Data.Text.unpack code <> " should not have type-checked")+ then fail (Text.unpack path <> " should not have type-checked") else return ()
@@ -11,28 +11,39 @@ , assertNormalizesToWith , assertNormalized , assertTypeChecks+ , discover+ , toDhallPath ) where +import Data.Bifunctor (first)+import Data.Text (Text)+import Dhall.Context (Context)+import Dhall.Core (Expr, Normalizer, ReifiedNormalizer(..))+import Dhall.Parser (Src)+import Dhall.TypeCheck (X)+import Prelude hiding (FilePath)+import Test.Tasty.HUnit+import Test.Tasty (TestTree)+import Turtle (FilePath, Pattern, Shell, fp)+ import qualified Control.Exception+import qualified Control.Foldl as Foldl import qualified Data.Functor-import Data.Bifunctor (first)-import Data.Text (Text)-import qualified Dhall.Core-import Dhall.Core (Expr, Normalizer)+import qualified Data.Text as Text import qualified Dhall.Context-import Dhall.Context (Context)+import qualified Dhall.Core import qualified Dhall.Import import qualified Dhall.Parser-import Dhall.Parser (Src) import qualified Dhall.TypeCheck-import Dhall.TypeCheck (X)-import Test.Tasty.HUnit+import qualified Test.Tasty as Tasty+import qualified Turtle normalize' :: Expr Src X -> Text normalize' = Dhall.Core.pretty . Dhall.Core.normalize normalizeWith' :: Normalizer X -> Expr Src X -> Text-normalizeWith' ctx = Dhall.Core.pretty . Dhall.Core.normalizeWith ctx+normalizeWith' ctx t =+ Dhall.Core.pretty (Dhall.Core.normalizeWith (Just (ReifiedNormalizer ctx)) t) code :: Text -> IO (Expr Src X) code = codeWith Dhall.Context.empty@@ -75,3 +86,29 @@ assertTypeChecks :: Text -> IO () assertTypeChecks text = Data.Functor.void (code text)++{-| Automatically run a test on all files in a directory tree that end in+ @A.dhall@+-}+discover :: Pattern Text -> (Text -> TestTree) -> Shell FilePath -> IO TestTree+discover pattern buildTest paths = do+ let shell = do+ path <- paths++ let pathText = Turtle.format fp path++ prefix : _ <- return (Turtle.match pattern pathText)++ return (buildTest prefix)++ tests <- Turtle.fold shell Foldl.list++ return (Tasty.testGroup "discover" tests)+++{-| Path names on Windows are not valid Dhall paths due to using backslashes+ instead of forwardslashes to separate path components. This utility fixes+ them if necessary+-}+toDhallPath :: Text -> Text+toDhallPath = Text.replace "\\" "/"
@@ -1,5 +1,6 @@- let MyType = < Empty : {} | Person : { name : Text, age : Natural } >-in [ MyType.Empty {=}+let MyType = < Empty | Person : { name : Text, age : Natural } >++in [ MyType.Empty -- Note the absence of any argument to `Empty` , MyType.Person { name = "John", age = 23 } , MyType.Person { name = "Amy" , age = 25 } ]
@@ -1,4 +1,6 @@-[ < Empty = {=} | Person : { age : Natural, name : Text } >-, < Person = { age = 23, name = "John" } | Empty : {} >-, < Person = { age = 25, name = "Amy" } | Empty : {} >+[ < Empty | Person : { age : Natural, name : Text } >.Empty+, < Empty | Person : { age : Natural, name : Text } >.Person+ { age = 23, name = "John" }+, < Empty | Person : { age : Natural, name : Text } >.Person+ { age = 25, name = "Amy" } ]