@@ -45,14 +45,13 @@ typeLiterals = mkPattern match
4545 match (TypeConstructor ctor) = Just $ text $ runProperName $ disqualify ctor
4646 match (TUnknown u) = Just $ text $ '_' : show u
4747 match (Skolem name s _) = Just $ text $ name ++ show s
48− match (ConstrainedType deps ty) = Just $ constraintsAsBox deps ty
4948 match REmpty = Just $ text "()"
5049 match row@RCons{} = Just $ prettyPrintRowWith '(' ')' row
5150 match _ = Nothing
5251
53−constraintsAsBox :: [(Qualified ProperName, [Type])] -> Type -> Box
54−constraintsAsBox [(pn, tys)] ty = text "(" <> constraintAsBox pn tys <> text ") => " <> typeAsBox ty
55−constraintsAsBox xs ty = vcat left (zipWith (\i (pn, tys) -> text (if i == 0 then "( " else ", ") <> constraintAsBox pn tys) [0 :: Int ..] xs) `before` (text ") => " <> typeAsBox ty)
52+constraintsAsBox :: [(Qualified ProperName, [Type])] -> Box -> Box
53+constraintsAsBox [(pn, tys)] ty = text "(" <> constraintAsBox pn tys <> text ") => " <> ty
54+constraintsAsBox xs ty = vcat left (zipWith (\i (pn, tys) -> text (if i == 0 then "( " else ", ") <> constraintAsBox pn tys) [0 :: Int ..] xs) `before` (text ") => " <> ty)
5655
5756constraintAsBox :: Qualified ProperName -> [Type] -> Box
5857constraintAsBox pn tys = hsep 1 left (text (runProperName (disqualify pn)) : map typeAtomAsBox tys)
@@ -114,6 +113,12 @@ insertPlaceholders = everywhereOnTypesTopDown convertForAlls . everywhereOnTypes
114113 go idents other = PrettyPrintForAll idents other
115114 convertForAlls other = other
116115
116+constrained :: Pattern () Type ([Constraint], Type)
117+constrained = mkPattern match
118+ where
119+ match (ConstrainedType deps ty) = Just (deps, ty)
120+ match _ = Nothing
121+
117122matchTypeAtom :: Pattern () Type Box
118123matchTypeAtom = typeLiterals <+> fmap ((`before` text ")") . (text "(" <>)) matchType
119124
@@ -125,6 +130,7 @@ matchType = buildPrettyPrinter operators matchTypeAtom
125130 OperatorTable [ [ AssocL typeApp $ \f x -> f `beforeWithSpace` x ]
126131 , [ AssocR appliedFunction $ \arg ret -> (arg <> text " ") `before` (text "-> " <> ret)
127132 ]
133+ , [ Wrap constrained $ \deps ty -> constraintsAsBox deps ty ]
128134 , [ Wrap forall_ $ \idents ty -> text ("forall " ++ unwords idents ++ ". ") <> ty ]
129135 , [ Wrap kinded $ \k ty -> ty `before` (text (" :: " ++ prettyPrintKind k)) ]
130136 ]