@@ -11,6 +11,7 @@ import Prelude hiding ((<>))
1111
1212import Control.Arrow (second )
1313
14+ import Data.Maybe (mapMaybe )
1415import Data.Text (Text )
1516import qualified Data.List.NonEmpty as NEL
1617import qualified Data.Monoid as Monoid ((<>) )
@@ -74,10 +75,10 @@ prettyPrintValue d (Case values binders) =
7475prettyPrintValue d (Let FromWhere ds val) =
7576 prettyPrintValue (d - 1 ) val //
7677 moveRight 2 (text " where" //
77- vcat left (map (prettyPrintDeclaration (d - 1 )) ds))
78+ vcat left (mapMaybe (prettyPrintDeclaration' (d - 1 )) ds))
7879prettyPrintValue d (Let FromLet ds val) =
7980 text " let" //
80- moveRight 2 (vcat left (map (prettyPrintDeclaration (d - 1 )) ds)) //
81+ moveRight 2 (vcat left (mapMaybe (prettyPrintDeclaration' (d - 1 )) ds)) //
8182 (text " in " <> prettyPrintValue (d - 1 ) val)
8283prettyPrintValue d (Do m els) =
8384 textT (maybe " " ((Monoid. <> " ." ) . runModuleName) m) <> text " do " <> vcat left (map (prettyPrintDoNotationElement (d - 1 )) els)
@@ -138,6 +139,12 @@ prettyPrintDeclaration d (BindingGroupDeclaration ds) =
138139 toDecl ((sa, nm), t, e) = ValueDecl sa nm t [] [GuardedExpr [] e]
139140prettyPrintDeclaration _ _ = internalError " Invalid argument to prettyPrintDeclaration"
140141
142+ prettyPrintDeclaration' :: Int -> Declaration -> Maybe Box
143+ prettyPrintDeclaration' d = \ case
144+ KindDeclaration {} -> Nothing
145+ TypeSynonymDeclaration {} -> Nothing
146+ decl -> Just $ prettyPrintDeclaration d decl
147+
141148prettyPrintCaseAlternative :: Int -> CaseAlternative -> Box
142149prettyPrintCaseAlternative d _ | d < 0 = ellipsis
143150prettyPrintCaseAlternative d (CaseAlternative binders result) =
@@ -183,7 +190,7 @@ prettyPrintDoNotationElement d (DoNotationBind binder val) =
183190 textT (prettyPrintBinder binder Monoid. <> " <- " ) <> prettyPrintValue d val
184191prettyPrintDoNotationElement d (DoNotationLet ds) =
185192 text " let" //
186- moveRight 2 (vcat left (map (prettyPrintDeclaration (d - 1 )) ds))
193+ moveRight 2 (vcat left (mapMaybe (prettyPrintDeclaration' (d - 1 )) ds))
187194prettyPrintDoNotationElement d (PositionedDoNotationElement _ _ el) = prettyPrintDoNotationElement d el
188195
189196prettyPrintBinderAtom :: Binder -> Text
0 commit comments