packages feed

dhall 1.41.0 → 1.41.1

raw patch · 5 files changed

+34/−22 lines, 5 filesdep ~aesondep ~pretty-simpledep ~vectorPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aeson, pretty-simple, vector

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+1.41.1++* [BUG FIX: Don't escape `?` path component when pretty-printing `with` expressions](https://github.com/dhall-lang/dhall-haskell/pull/2392)+ 1.41.0  * [Support standard version 22.0.0](https://github.com/dhall-lang/dhall-lang/releases/tag/v22.0.0)
dhall.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: 2.4 Name: dhall-Version: 1.41.0+Version: 1.41.1 Build-Type: Simple License: BSD-3-Clause License-File: LICENSE
src/Dhall/Pretty/Internal.hs view
@@ -529,8 +529,12 @@ prettyAnyLabel :: Text -> Doc Ann prettyAnyLabel = prettyLabelShared True -prettyAnyLabels :: Foldable list => list (Maybe Src, Text, Maybe Src) -> Doc Ann-prettyAnyLabels keys = Pretty.group (Pretty.flatAlt long short)+prettyKeys+    :: Foldable list+    => (key -> Doc Ann)+    -> list (Maybe Src, key, Maybe Src)+    -> Doc Ann+prettyKeys prettyK keys = Pretty.group (Pretty.flatAlt long short)   where     short = (mconcat . Pretty.punctuate dot . map prettyKey . toList) keys @@ -550,7 +554,7 @@         . Pretty.punctuate Pretty.hardline         . Data.Maybe.catMaybes         $ [ renderSrcMaybe mSrc0-          , Just (prettyAnyLabel key)+          , Just (prettyK key)           , renderSrcMaybe mSrc1           ] @@ -829,11 +833,11 @@             <>  Pretty.align (keyword "with" <> " " <> update)          (update, _) =-            prettyKeyValue prettyOperatorExpression equals-                (makeKeyValue (fmap toText b) c)+            prettyKeyValue prettyKey prettyOperatorExpression equals+                (makeKeyValue b c) -        toText  WithQuestion  = "?"-        toText (WithLabel k ) = k+        prettyKey (WithLabel text) = prettyAnyLabel text+        prettyKey  WithQuestion    = syntax "?"     prettyExpression (Assert a) =         Pretty.group (Pretty.flatAlt long short)       where@@ -1417,11 +1421,12 @@      prettyKeyValue         :: Pretty a-        => (Expr Src a -> Doc Ann)+        => (key -> Doc Ann)+        -> (Expr Src a -> Doc Ann)         -> Doc Ann-        -> KeyValue Src a+        -> KeyValue key Src a         -> (Doc Ann, Doc Ann)-    prettyKeyValue prettyValue separator (KeyValue key mSrc val) =+    prettyKeyValue prettyKey prettyValue separator (KeyValue key mSrc val) =         duplicate (Pretty.group (Pretty.flatAlt long short))       where         completion _T r =@@ -1433,7 +1438,7 @@                     _ ->                         prettySelectorExpression r -        short = prettyAnyLabels key+        short = prettyKeys prettyKey key             <>  " "             <>  separator             <>  " "@@ -1443,7 +1448,7 @@             <>  prettyValue val          long =  Pretty.align-                    (   prettyAnyLabels key+                    (   prettyKeys prettyKey key                     <>  preSeparator                     )             <>  separator@@ -1533,7 +1538,7 @@     prettyRecord :: Pretty a => Map Text (RecordField Src a) -> Doc Ann     prettyRecord =         ( braces-        . map (prettyKeyValue prettyExpression colon . adapt)+        . map (prettyKeyValue prettyAnyLabel prettyExpression colon . adapt)         . Map.toList         )       where@@ -1590,12 +1595,12 @@                     | Var (V key' 0) <- Dhall.Syntax.shallowDenote val                     , key == key'                     , not (containsComment mSrc2) ->-                        duplicate (prettyAnyLabels [(mSrc0, key, mSrc1)])+                        duplicate (prettyKeys prettyAnyLabel [(mSrc0, key, mSrc1)])                 _ ->-                    prettyKeyValue prettyExpression equals kv+                    prettyKeyValue prettyAnyLabel prettyExpression equals kv      prettyAlternative (key, Just val) =-        prettyKeyValue prettyExpression colon (makeKeyValue (pure key) val)+        prettyKeyValue prettyAnyLabel prettyExpression colon (makeKeyValue (pure key) val)     prettyAlternative (key, Nothing) =         duplicate (prettyAnyLabel key) @@ -1793,13 +1798,13 @@ pretty_ :: Pretty a => a -> Text pretty_ = prettyToStrictText -data KeyValue s a = KeyValue-    { _keyValueKeys  :: NonEmpty (Maybe s, Text, Maybe s)+data KeyValue k s a = KeyValue+    { _keyValueKeys  :: NonEmpty (Maybe s, k , Maybe s)     , _keyValueSrc   :: Maybe s     , _keyValueValue :: Expr s a     } -makeKeyValue :: NonEmpty Text -> Expr s a -> KeyValue s a+makeKeyValue :: NonEmpty key -> Expr s a -> KeyValue key s a makeKeyValue keys expr = KeyValue (adapt <$> keys) Nothing expr   where     adapt key = (Nothing, key, Nothing)@@ -1807,10 +1812,11 @@ {- This utility function converts    `{ x = { y = { z = 1 } } }` to `{ x.y.z = 1 }` -}-consolidateRecordLiteral :: Map Text (RecordField Src a) -> [KeyValue Src a]+consolidateRecordLiteral+    :: Map Text (RecordField Src a) -> [KeyValue Text Src a] consolidateRecordLiteral = concatMap adapt . Map.toList   where-    adapt :: (Text, RecordField Src a) -> [KeyValue Src a]+    adapt :: (Text, RecordField Src a) -> [KeyValue Text Src a]     adapt (key, RecordField mSrc0 val mSrc1 mSrc2)         | not (containsComment mSrc2)         , RecordLit m <- e
+ tests/format/withQuestionA.dhall view
@@ -0,0 +1,1 @@+λ(x : Optional Natural) → x with ? = 2
+ tests/format/withQuestionB.dhall view
@@ -0,0 +1,1 @@+λ(x : Optional Natural) → x with ? = 2