@@ -14,8 +14,7 @@
1414-----------------------------------------------------------------------------
1515
1616module Language.PureScript.Pretty.Kinds (
17− prettyPrintKind,
18− kindAsBox
17+ prettyPrintKind
1918) where
2019
2120import Data.Maybe (fromMaybe)
@@ -24,15 +23,14 @@ import Control.Arrow (ArrowPlus(..))
2423import Control.PatternArrows
2524
2625import Language.PureScript.Kinds
26+import Language.PureScript.Pretty.Common
2727
28−import Text.PrettyPrint.Boxes (Box(), text, render, (<>))
29−
30−typeLiterals :: Pattern () Kind Box
28+typeLiterals :: Pattern () Kind String
3129typeLiterals = mkPattern match
3230 where
33− match Star = Just $ text "*"
34− match Bang = Just $ text "!"
35− match (KUnknown u) = Just $ text $ 'u' : show u
31+ match Star = Just "*"
32+ match Bang = Just "!"
33+ match (KUnknown u) = Just $ 'u' : show u
3634 match _ = Nothing
3735
3836matchRow :: Pattern () Kind ((), Kind)
@@ -49,15 +47,12 @@ funKind = mkPattern match
4947
5048-- | Generate a pretty-printed string representing a Kind
5149prettyPrintKind :: Kind -> String
52−prettyPrintKind = render . kindAsBox
53−
54−kindAsBox :: Kind -> Box
55−kindAsBox = fromMaybe (error "Incomplete pattern") . pattern matchKind ()
50+prettyPrintKind = fromMaybe (error "Incomplete pattern") . pattern matchKind ()
5651 where
57− matchKind :: Pattern () Kind Box
58− matchKind = buildPrettyPrinter operators (typeLiterals <+> fmap ((text "(" <>) . (<> text ")")) matchKind)
52+ matchKind :: Pattern () Kind String
53+ matchKind = buildPrettyPrinter operators (typeLiterals <+> fmap parens matchKind)
5954
60− operators :: OperatorTable () Kind Box
55+ operators :: OperatorTable () Kind String
6156 operators =
62− OperatorTable [ [ Wrap matchRow $ \_ k -> text "# " <> k]
63− , [ AssocR funKind $ \arg ret -> arg <> text " -> " <> ret ] ]
57+ OperatorTable [ [ Wrap matchRow $ \_ k -> "# " ++ k]
58+ , [ AssocR funKind $ \arg ret -> arg ++ " -> " ++ ret ] ]