on master help sign in
Get rid of "pretty" dependency
e7a8310Evan Czaplicki
compiler/src/Elm/Compiler/Type.hs+18−23
@@ -16,8 +16,8 @@ module Elm.Compiler.Type
16
16
17import qualified Data.Text as Text
17import qualified Data.Text as Text
18import qualified Data.Text.Encoding as Text
18import qualified Data.Text.Encoding as Text
19−import qualified Text.PrettyPrint as P
19+import qualified Text.PrettyPrint.ANSI.Leijen as P
20−import Text.PrettyPrint ((<+>))
20+import Text.PrettyPrint.ANSI.Leijen ((<+>))
21
21
22import qualified AST.Source as Src
22import qualified AST.Source as Src
23import qualified Elm.Name as N
23import qualified Elm.Name as N
@@ -63,15 +63,12 @@ data Format = OneLine | MultiLine
63
63
64toString :: Format -> Type -> String
64toString :: Format -> Type -> String
65toString format tipe =
65toString format tipe =
66− let
67− mode =
68− case format of
66+ case format of
69− OneLine ->
67+ OneLine ->
70− P.OneLineMode
68+ P.displayS (P.renderPretty 1.0 maxBound (toDoc None tipe)) ""
69+
71− MultiLine ->
70+ MultiLine ->
72− P.PageMode
73− in
74− P.renderStyle (P.Style mode 80 1.0) (toDoc None tipe)
71+ P.displayS (P.renderPretty 1.0 80 (toDoc None tipe)) ""
75
72
76
73
77data Context = None | InType | InFunction
74data Context = None | InType | InFunction
@@ -114,11 +111,11 @@ toDoc context tipe =
114
111
115 _ ->
112 _ ->
116 let
113 let
114+ docName =
115+ P.text (N.toString name)
116+
117 application =
117 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)
122 in
119 in
123 case context of
120 case context of
124 InType ->
121 InType ->
@@ -139,14 +136,12 @@ toDoc context tipe =
139 ]
136 ]
140
137
141 Just x ->
138 Just x ->
142− P.hang
139+ P.hang 4 $
140+ P.sep
143− ("{" <+> P.text (N.toString x) <+> "|")
141+ [ "{" <+> P.text (N.toString x) <+> "|"
144− 4
145− (P.sep
146− [ P.sep (P.punctuate "," (map entryToDoc fields))
142+ , P.sep (P.punctuate "," (map entryToDoc fields))
147− , "}"
143+ , "}"
148− ]
144+ ]
149− )
150
145
151
146
152entryToDoc :: (N.Name, Type) -> P.Doc
147entryToDoc :: (N.Name, Type) -> P.Doc
elm.cabal−1
@@ -242,7 +242,6 @@ Executable elm
242 mtl >= 2.2.1 && < 3,
242 mtl >= 2.2.1 && < 3,
243 network >= 2.4 && < 2.7,
243 network >= 2.4 && < 2.7,
244 parsec,
244 parsec,
245− pretty >= 1.0 && < 2.0,
246 process,
245 process,
247 raw-strings-qq,
246 raw-strings-qq,
248 scientific,
247 scientific,