@@ -75,18 +75,8 @@ renderChildDeclarationWithOptions opts ChildDeclaration{..} =
7575 [ keywordInstance
7676 , ident cdeclTitle
7777 , syntax "::"
78− ] ++ maybe [] (:[]) constraints'
78+ ] ++ maybe [] (:[]) (renderConstraints constraints)
7979 ++ [ renderType' ty ]
80− where
81− constraints'
82− | null constraints = Nothing
83− | otherwise = Just $
84− syntax "("
85− <> renderedConstraints
86− <> syntax ")" <> sp <> syntax "=>"
87−
88− renderedConstraints = mintersperse (syntax "," <> sp)
89− (map renderConstraint constraints)
9080 ChildDataConstructor args ->
9181 [ renderType' typeApp' ]
9282 where
@@ -102,8 +92,26 @@ renderChildDeclarationWithOptions opts ChildDeclaration{..} =
10292 renderType' = renderTypeWithOptions opts
10393
10494renderConstraint :: (P.Qualified P.ProperName, [P.Type]) -> RenderedCode
105−renderConstraint (pn, tys) =
106− 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)
107115
108116notQualified :: String -> P.Qualified P.ProperName
109117notQualified = P.Qualified Nothing . P.ProperName