@@ -104,10 +104,11 @@ prettyString (DoubleQuoted parts) = "\"" <> foldMap prettyPart parts <> "\""
104104 where
105105 -- It serializes Text -> String, because the helper code is done for String,
106106 -- please, can someone break that code.
107- prettyPart (Plain t) = pretty . foldMap escape . toString $ t
107+ prettyPart (Plain t) = pretty . dollarEscape . toText . foldMap escape . toString $ t
108108 prettyPart EscapedNewline = " ''\\ n"
109109 prettyPart (Antiquoted r) = " ${" <> withoutParens r <> " }"
110110 escape ' "' = " \\\" "
111+ escape ' $' = " $" -- do not print $ as \$ if no { is following
111112 escape x =
112113 maybe
113114 (one x)
@@ -382,6 +383,10 @@ prettyNThunk t =
382383 " (" <> fold (one " thunk from: " <> (prettyOriginExpr . _originExpr <$> ps)) <> " )"
383384 ]
384385
386+ -- | dollarEscape for double quoted string
387+ dollarEscape :: Text -> Text
388+ dollarEscape = replace " ${" " \\ ${"
389+
385390-- | This function is used only by the testing code.
386391printNix :: forall t f m . MonadDataContext f m => NValue t f m -> Text
387392printNix = iterNValueByDiscardWith thk phi
@@ -390,7 +395,7 @@ printNix = iterNValueByDiscardWith thk phi
390395
391396 phi :: NValue' t f m Text -> Text
392397 phi (NVConstant' a ) = atomText a
393- phi (NVStr' ns) = show $ ignoreContext ns
398+ phi (NVStr' ns) = dollarEscape $ show $ ignoreContext ns
394399 phi (NVList' l ) = " [ " <> unwords l <> " ]"
395400 phi (NVSet' _ s) =
396401 " { " <>
0 commit comments