Text literals can display non-ascii chars

This commit is contained in:
pete-ts 2020-04-17 22:19:38 +01:00
parent 4b20ca7768
commit 34b647fb7c
4 changed files with 37 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import qualified Data.Map as Map
import qualified Data.Set as Set
import Data.Text ( splitOn, unpack )
import qualified Data.Text as Text
import qualified Text.Show.Unicode as U
import Data.Vector ( )
import Unison.ABT ( pattern AbsN', reannotateUp, annotation )
import qualified Unison.ABT as ABT
@ -187,7 +188,7 @@ pretty0
-- metaprograms), then it needs to be able to print them (and then the
-- parser ought to be able to parse them, to maintain symmetry.)
Boolean' b -> fmt S.BooleanLiteral $ if b then l "true" else l "false"
Text' s -> fmt S.TextLiteral $ l $ show s
Text' s -> fmt S.TextLiteral $ l $ U.ushow s
Char' c -> fmt S.CharLiteral $ l $ case showEscapeChar c of
Just c -> "?\\" ++ [c]
Nothing -> '?': [c]

View File

@ -201,7 +201,8 @@ library
unison-core,
unliftio,
util,
vector
vector,
unicode-show
ghc-options: -Wall -O0 -fno-warn-name-shadowing -fno-warn-missing-pattern-synonym-signatures
default-extensions:

View File

@ -0,0 +1,5 @@
```unison
> "Rúnar"
> "῎Ανδρα μοι ἔννεπε, Μοῦσα, πολύτροπον"
> "古池や蛙飛びこむ水の音"
```

View File

@ -0,0 +1,28 @@
```unison
> "Rúnar"
> "῎Ανδρα μοι ἔννεπε, Μοῦσα, πολύτροπον"
> "古池や蛙飛びこむ水の音"
```
```ucm
scratch.u changed.
Now evaluating any watch expressions (lines starting with
`>`)... Ctrl+C cancels.
1 | > "Rúnar"
"Rúnar"
2 | > "῎Ανδρα μοι ἔννεπε, Μοῦσα, πολύτροπον"
"῎Ανδρα μοι ἔννεπε, Μοῦσα, πολύτροπον"
3 | > "古池や蛙飛びこむ水の音"
"古池や蛙飛びこむ水の音"
```