@@ -8,7 +8,7 @@ module Reporting.Doc
88 , P.red, P.cyan, P.magenta, P.green, P.blue, P.black, P.yellow
99 , P.dullred, P.dullcyan, P.dullyellow
1010
11− , fromString, fromText, fromName, fromInt, fromUtf8
11+ , fromChars, fromName, fromInt, fromUtf8
1212 , toAnsi, toString, toLine
1313 , encode
1414
@@ -26,17 +26,12 @@ import Prelude hiding (cycle)
2626import qualified Data.List as List
2727import Data.Monoid ((<>))
2828import qualified Data.Name as Name
29−import qualified Data.Text as Text
30−import qualified Data.Text.Lazy as TL
31−import qualified Data.Text.Lazy.Builder as TB
3229import qualified Data.Utf8 as Utf8
3330import qualified System.Console.ANSI.Types as Ansi
3431import System.IO (Handle)
3532import qualified Text.PrettyPrint.ANSI.Leijen as P
3633
3734import qualified Data.Index as Index
38−import qualified Elm.Compiler.Version as Compiler
39−import qualified Elm.Package as Pkg
4035import qualified Json.Encode as E
4136
4237
@@ -44,19 +39,14 @@ import qualified Json.Encode as E
4439-- FROM
4540
4641
47−fromString :: String -> P.Doc
48−fromString =
42+fromChars :: String -> P.Doc
43+fromChars =
4944 P.text
5045
5146
52−fromText :: Text.Text -> P.Doc
53−fromText txt =
54− P.text (Text.unpack txt)
55−
56−
5747fromName :: Name.Name -> P.Doc
5848fromName name =
59− P.text (Name.toString name)
49+ P.text (Name.toChars name)
6050
6151
6252fromInt :: Int -> P.Doc
@@ -64,9 +54,9 @@ fromInt n =
6454 P.text (show n)
6555
6656
67−fromUtf8 :: Utf8.Utf8 -> P.Doc
57+fromUtf8 :: Utf8.String -> P.Doc
6858fromUtf8 utf8 =
69− P.text (Utf8.toString utf8)
59+ P.text (Utf8.toChars utf8)
7060
7161
7262
@@ -159,12 +149,12 @@ fancyLink word before fileName after =
159149
160150makeLink :: String -> String
161151makeLink fileName =
162− "<https://elm-lang.org/" <> Pkg.versionToString Compiler.version <> "/" <> fileName <> ">"
152+ "<https://elm-lang.org/" <> error "TODO V.toString V.compiler" <> "/" <> fileName <> ">"
163153
164154
165155makeNakedLink :: String -> String
166156makeNakedLink fileName =
167− "https://elm-lang.org/" <> Pkg.versionToString Compiler.version <> "/" <> fileName
157+ "https://elm-lang.org/" <> error "TODO V.toString V.compiler" <> "/" <> fileName
168158
169159
170160reflowLink :: String -> String -> String -> P.Doc
@@ -267,8 +257,10 @@ data Color
267257 | WHITE
268258
269259
270−toJsonHelp :: Style -> [TB.Builder] -> P.SimpleDoc -> [E.Value]
260+toJsonHelp :: Style -> [a] -> P.SimpleDoc -> [E.Value]
271261toJsonHelp style revChunks simpleDoc =
262+ error "TODO generate json on errors" style revChunks simpleDoc sgrToStyle encodeColor
263+{-
272264 case simpleDoc of
273265 P.SFail ->
274266 error $
@@ -294,7 +286,7 @@ toJsonHelp style revChunks simpleDoc =
294286spaces :: Int -> TB.Builder
295287spaces n =
296288 TB.fromText (Text.replicate n " ")
297−
289+-}
298290
299291sgrToStyle :: [Ansi.SGR] -> Style -> Style
300292sgrToStyle sgrs style@(Style bold underline color) =
@@ -356,35 +348,28 @@ toColor layer intensity color =
356348 Ansi.White -> pick White WHITE
357349 Ansi.Black -> pick Black BLACK
358350
359−
351+{-
360352encodeChunks :: Style -> [TB.Builder] -> E.Value
361353encodeChunks (Style bold underline color) revChunks =
362354 let
363− text =
364− case revChunks of
365− [] ->
366− Text.empty
367−
368− c:cs ->
369− TL.toStrict $ TB.toLazyText $
370− List.foldl' (\builder chunk -> chunk <> builder) c cs
355+ !str = Utf8.concat (reverse revChunks)
371356 in
372357 case color of
373358 Nothing | not bold && not underline ->
374− E.text text
359+ E.string str
375360
376361 _ ->
377362 E.object
378363 [ ("bold", E.bool bold)
379364 , ("underline", E.bool underline)
380365 , ("color", maybe E.null encodeColor color)
381− , ("string", E.text text)
366+ , ("string", E.string str)
382367 ]
383−
368+-}
384369
385370encodeColor :: Color -> E.Value
386371encodeColor color =
387− E.text $
372+ E.string $
388373 case color of
389374 Red -> "red"
390375 RED -> "RED"