@@ -14,8 +14,7 @@
14-----------------------------------------------------------------------------
14-----------------------------------------------------------------------------
16module Language.PureScript.Pretty.Kinds (
16module Language.PureScript.Pretty.Kinds (
17− prettyPrintKind,
17+ prettyPrintKind
21import Data.Maybe (fromMaybe)
20import Data.Maybe (fromMaybe)
@@ -24,15 +23,14 @@ import Control.Arrow (ArrowPlus(..))
24import Control.PatternArrows
23import Control.PatternArrows
26import Language.PureScript.Kinds
25import Language.PureScript.Kinds
26+import Language.PureScript.Pretty.Common
28−import Text.PrettyPrint.Boxes (Box(), text, render, (<>))
30−typeLiterals :: Pattern () Kind Box
28+typeLiterals :: Pattern () Kind String
31typeLiterals = mkPattern match
29typeLiterals = mkPattern match
33− match Star = Just $ text "*"
31+ match Star = Just "*"
34− match Bang = Just $ text "!"
32+ match Bang = Just "!"
35− match (KUnknown u) = Just $ text $ 'u' : show u
33+ match (KUnknown u) = Just $ 'u' : show u
36 match _ = Nothing
34 match _ = Nothing
38matchRow :: Pattern () Kind ((), Kind)
36matchRow :: Pattern () Kind ((), Kind)
@@ -49,15 +47,12 @@ funKind = mkPattern match
50-- | Generate a pretty-printed string representing a Kind
48-- | Generate a pretty-printed string representing a Kind
51prettyPrintKind :: Kind -> String
49prettyPrintKind :: Kind -> String
52−prettyPrintKind = render . kindAsBox
54−kindAsBox :: Kind -> Box
55−kindAsBox = fromMaybe (error "Incomplete pattern") . pattern matchKind ()
50+prettyPrintKind = fromMaybe (error "Incomplete pattern") . pattern matchKind ()
57− matchKind :: Pattern () Kind Box
52+ matchKind :: Pattern () Kind String
58− matchKind = buildPrettyPrinter operators (typeLiterals <+> fmap ((text "(" <>) . (<> text ")")) matchKind)
53+ matchKind = buildPrettyPrinter operators (typeLiterals <+> fmap parens matchKind)
60− operators :: OperatorTable () Kind Box
55+ operators :: OperatorTable () Kind String
61 operators =
56 operators =
62− OperatorTable [ [ Wrap matchRow $ \_ k -> text "# " <> k]
57+ OperatorTable [ [ Wrap matchRow $ \_ k -> "# " ++ k]
63− , [ AssocR funKind $ \arg ret -> arg <> text " -> " <> ret ] ]
58+ , [ AssocR funKind $ \arg ret -> arg ++ " -> " ++ ret ] ]