@@ -18,33 +18,36 @@ import Language.PureScript.Docs.RenderedCode
1818import Language.PureScript.Docs.Utils.MonoidExtras
1919
2020renderDeclaration :: Declaration -> RenderedCode
21−renderDeclaration Declaration{..} =
21+renderDeclaration = renderDeclarationWithOptions defaultRenderTypeOptions
22+
23+renderDeclarationWithOptions :: RenderTypeOptions -> Declaration -> RenderedCode
24+renderDeclarationWithOptions opts Declaration{..} =
2225 mintersperse sp $ case declInfo of
2326 ValueDeclaration ty ->
2427 [ ident declTitle
2528 , syntax "::"
26− , renderType ty
29+ , renderType' ty
2730 ]
2831 DataDeclaration dtype args ->
2932 [ keyword (show dtype)
30− , renderType (typeApp declTitle args)
33+ , renderType' (typeApp declTitle args)
3134 ]
3235 ExternDataDeclaration kind' ->
3336 [ keywordData
34− , renderType (P.TypeConstructor (notQualified declTitle))
37+ , renderType' (P.TypeConstructor (notQualified declTitle))
3538 , syntax "::"
3639 , renderKind kind'
3740 ]
3841 TypeSynonymDeclaration args ty ->
3942 [ keywordType
40− , renderType (typeApp declTitle args)
43+ , renderType' (typeApp declTitle args)
4144 , syntax "="
42− , renderType ty
45+ , renderType' ty
4346 ]
4447 TypeClassDeclaration args implies ->
4548 [ keywordClass ]
4649 ++ maybe [] (:[]) superclasses
47− ++ [renderType (typeApp declTitle args)]
50+ ++ [renderType' (typeApp declTitle args)]
4851 ++ if any (isTypeClassMember . cdeclInfo) declChildren
4952 then [keywordWhere]
5053 else []
@@ -59,28 +62,23 @@ renderDeclaration Declaration{..} =
5962
6063 isTypeClassMember (ChildTypeClassMember _) = True
6164 isTypeClassMember _ = False
65+ where
66+ renderType' = renderTypeWithOptions opts
6267
6368renderChildDeclaration :: ChildDeclaration -> RenderedCode
64−renderChildDeclaration ChildDeclaration{..} =
69+renderChildDeclaration = renderChildDeclarationWithOptions defaultRenderTypeOptions
70+
71+renderChildDeclarationWithOptions :: RenderTypeOptions -> ChildDeclaration -> RenderedCode
72+renderChildDeclarationWithOptions opts ChildDeclaration{..} =
6573 mintersperse sp $ case cdeclInfo of
6674 ChildInstance constraints ty ->
6775 [ keywordInstance
6876 , ident cdeclTitle
6977 , syntax "::"
70− ] ++ maybe [] (:[]) constraints'
71− ++ [ renderType ty ]
72− where
73− constraints'
74− | null constraints = Nothing
75− | otherwise = Just $
76− syntax "("
77− <> renderedConstraints
78− <> syntax ")" <> sp <> syntax "=>"
79−
80− renderedConstraints = mintersperse (syntax "," <> sp)
81− (map renderConstraint constraints)
78+ ] ++ maybe [] (:[]) (renderConstraints constraints)
79+ ++ [ renderType' ty ]
8280 ChildDataConstructor args ->
83− [ renderType typeApp' ]
81+ [ renderType' typeApp' ]
8482 where
8583 typeApp' = foldl P.TypeApp ctor' args
8684 ctor' = P.TypeConstructor (notQualified cdeclTitle)
@@ -88,12 +86,32 @@ renderChildDeclaration ChildDeclaration{..} =
8886 ChildTypeClassMember ty ->
8987 [ ident cdeclTitle
9088 , syntax "::"
91− , renderType ty
89+ , renderType' ty
9290 ]
91+ where
92+ renderType' = renderTypeWithOptions opts
9393
9494renderConstraint :: (P.Qualified P.ProperName, [P.Type]) -> RenderedCode
95−renderConstraint (pn, tys) =
96− renderType $ foldl P.TypeApp (P.TypeConstructor pn) tys
95+renderConstraint = renderConstraintWithOptions defaultRenderTypeOptions
96+
97+renderConstraintWithOptions :: RenderTypeOptions -> (P.Qualified P.ProperName, [P.Type]) -> RenderedCode
98+renderConstraintWithOptions opts (pn, tys) =
99+ renderTypeWithOptions opts $ foldl P.TypeApp (P.TypeConstructor pn) tys
100+
101+renderConstraints :: [P.Constraint] -> Maybe RenderedCode
102+renderConstraints = renderConstraintsWithOptions defaultRenderTypeOptions
103+
104+renderConstraintsWithOptions :: RenderTypeOptions -> [P.Constraint] -> Maybe RenderedCode
105+renderConstraintsWithOptions opts constraints
106+ | null constraints = Nothing
107+ | otherwise = Just $
108+ syntax "("
109+ <> renderedConstraints
110+ <> syntax ")" <> sp <> syntax "=>"
111+ where
112+ renderedConstraints =
113+ mintersperse (syntax "," <> sp)
114+ (map (renderConstraintWithOptions opts) constraints)
97115
98116notQualified :: String -> P.Qualified P.ProperName
99117notQualified = P.Qualified Nothing . P.ProperName