Skip to content

Commit

Permalink
Pretty print readable unicode characters (#2041)
Browse files Browse the repository at this point in the history
Closes #1943
  • Loading branch information
nitinprakash96 authored Jul 15, 2024
1 parent 1f1d191 commit bd552e3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/swarm-lang/Swarm/Language/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

------------------------------------------------------------
Expand Down Expand Up @@ -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 -> "<a" <> pretty r <> ">"
Expand Down
1 change: 1 addition & 0 deletions swarm.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions test/unit/TestEval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bd552e3

Please sign in to comment.