diff --git a/src/swarm-lang/Swarm/Language/Pretty.hs b/src/swarm-lang/Swarm/Language/Pretty.hs index 04cfa0cf1..c54663484 100644 --- a/src/swarm-lang/Swarm/Language/Pretty.hs +++ b/src/swarm-lang/Swarm/Language/Pretty.hs @@ -36,6 +36,7 @@ import Swarm.Language.Syntax.Direction import Swarm.Language.Typecheck import Swarm.Language.Types import Swarm.Util (number, showEnum, showLowT, unsnocNE) +import Text.Show.Unicode (ushow) import Witch ------------------------------------------------------------ @@ -271,7 +272,7 @@ instance PrettyPrec (Term' ty) where TDir d -> ppr d TInt n -> pretty n TAntiInt v -> "$int:" <> pretty v - TText s -> fromString (show s) + TText s -> fromString (ushow s) TAntiText v -> "$str:" <> pretty v TBool b -> bool "false" "true" b TRobot r -> " pretty r <> ">" diff --git a/swarm.cabal b/swarm.cabal index ffc098a67..15ee9ba62 100644 --- a/swarm.cabal +++ b/swarm.cabal @@ -191,6 +191,7 @@ library swarm-lang terminal-size >=0.3 && <1.0, text, text-rope >=0.2 && <0.3, + unicode-show >=0.1 && <0.2, vector, vty, witch, diff --git a/test/unit/TestEval.hs b/test/unit/TestEval.hs index 09f6affac..37cc7ee61 100644 --- a/test/unit/TestEval.hs +++ b/test/unit/TestEval.hs @@ -227,6 +227,9 @@ testEval g = , testCase "format function" ("format (\\x. x + 1)" `evaluatesTo` VText "\\x. x + 1") + , testCase + "format forall" + ("format \"∀\"" `evaluatesTo` VText "\"∀\"") , testCase "concat" ("\"x = \" ++ format (2+3) ++ \"!\"" `evaluatesTo` VText "x = 5!") @@ -346,6 +349,7 @@ testEval g = where tquote :: String -> Text tquote = T.pack . show + throwsError :: Text -> (Text -> Bool) -> Assertion throwsError tm p = do result <- evaluate tm