on master help sign in
Get rid of "pretty" dependency

I _think_ the logic for (toString OneLine) will be fine in practice, but I’m not 100% certain. I’d like for there to be a certain path.

commite7a83100aa5a327cd1e80b6242c9d00788a82633 authorEvan Czaplicki <evancz@users.noreply.github.com> dateThu 22 Feb 2018, 17:03 (9 years ago) parent0962115
2 files changed+18−24
compiler/src/Elm/Compiler/Type.hs+18−23 elm.cabal−1
compiler/src/Elm/Compiler/Type.hs+18−23
@@ -16,8 +16,8 @@ module Elm.Compiler.Type
1616
1717import qualified Data.Text as Text
1818import qualified Data.Text.Encoding as Text
19−import qualified Text.PrettyPrint as P
20−import Text.PrettyPrint ((<+>))
19+import qualified Text.PrettyPrint.ANSI.Leijen as P
20+import Text.PrettyPrint.ANSI.Leijen ((<+>))
2121
2222import qualified AST.Source as Src
2323import qualified Elm.Name as N
@@ -63,15 +63,12 @@ data Format = OneLine | MultiLine
6363
6464toString :: Format -> Type -> String
6565toString format tipe =
66− let
67− mode =
68− case format of
69− OneLine ->
70− P.OneLineMode
71− MultiLine ->
72− P.PageMode
73− in
74− P.renderStyle (P.Style mode 80 1.0) (toDoc None tipe)
66+ case format of
67+ OneLine ->
68+ P.displayS (P.renderPretty 1.0 maxBound (toDoc None tipe)) ""
69+
70+ MultiLine ->
71+ P.displayS (P.renderPretty 1.0 80 (toDoc None tipe)) ""
7572
7673
7774data Context = None | InType | InFunction
@@ -114,11 +111,11 @@ toDoc context tipe =
114111
115112 _ ->
116113 let
114+ docName =
115+ P.text (N.toString name)
116+
117117 application =
118− P.hang
119− (P.text (N.toString name))
120− 2
121− (P.sep $ map (toDoc InType) args)
118+ P.hang 2 $ P.sep (docName : map (toDoc InType) args)
122119 in
123120 case context of
124121 InType ->
@@ -139,14 +136,12 @@ toDoc context tipe =
139136 ]
140137
141138 Just x ->
142− P.hang
143− ("{" <+> P.text (N.toString x) <+> "|")
144− 4
145− (P.sep
146− [ P.sep (P.punctuate "," (map entryToDoc fields))
147− , "}"
148− ]
149− )
139+ P.hang 4 $
140+ P.sep
141+ [ "{" <+> P.text (N.toString x) <+> "|"
142+ , P.sep (P.punctuate "," (map entryToDoc fields))
143+ , "}"
144+ ]
150145
151146
152147entryToDoc :: (N.Name, Type) -> P.Doc
elm.cabal−1
@@ -242,7 +242,6 @@ Executable elm
242242 mtl >= 2.2.1 && < 3,
243243 network >= 2.4 && < 2.7,
244244 parsec,
245− pretty >= 1.0 && < 2.0,
246245 process,
247246 raw-strings-qq,
248247 scientific,