@@ -75,18 +75,8 @@ renderChildDeclarationWithOptions opts ChildDeclaration{..} =
75 [ keywordInstance
75 [ keywordInstance
76 , ident cdeclTitle
76 , ident cdeclTitle
77 , syntax "::"
77 , syntax "::"
78− ] ++ maybe [] (:[]) constraints'
78+ ] ++ maybe [] (:[]) (renderConstraints constraints)
79 ++ [ renderType' ty ]
79 ++ [ renderType' ty ]
82− | null constraints = Nothing
85− <> renderedConstraints
86− <> syntax ")" <> sp <> syntax "=>"
88− renderedConstraints = mintersperse (syntax "," <> sp)
89− (map renderConstraint constraints)
90 ChildDataConstructor args ->
80 ChildDataConstructor args ->
91 [ renderType' typeApp' ]
81 [ renderType' typeApp' ]
@@ -102,8 +92,26 @@ renderChildDeclarationWithOptions opts ChildDeclaration{..} =
102 renderType' = renderTypeWithOptions opts
92 renderType' = renderTypeWithOptions opts
104renderConstraint :: (P.Qualified P.ProperName, [P.Type]) -> RenderedCode
94renderConstraint :: (P.Qualified P.ProperName, [P.Type]) -> RenderedCode
105−renderConstraint (pn, tys) =
95+renderConstraint = renderConstraintWithOptions defaultRenderTypeOptions
97+renderConstraintWithOptions :: RenderTypeOptions -> (P.Qualified P.ProperName, [P.Type]) -> RenderedCode
98+renderConstraintWithOptions opts (pn, tys) =
106− renderType $ foldl P.TypeApp (P.TypeConstructor pn) tys
99+ renderTypeWithOptions opts $ foldl P.TypeApp (P.TypeConstructor pn) tys
101+renderConstraints :: [P.Constraint] -> Maybe RenderedCode
102+renderConstraints = renderConstraintsWithOptions defaultRenderTypeOptions
104+renderConstraintsWithOptions :: RenderTypeOptions -> [P.Constraint] -> Maybe RenderedCode
105+renderConstraintsWithOptions opts constraints
106+ | null constraints = Nothing
107+ | otherwise = Just $
109+ <> renderedConstraints
110+ <> syntax ")" <> sp <> syntax "=>"
112+ renderedConstraints =
113+ mintersperse (syntax "," <> sp)
114+ (map (renderConstraintWithOptions opts) constraints)
108notQualified :: String -> P.Qualified P.ProperName
116notQualified :: String -> P.Qualified P.ProperName
109notQualified = P.Qualified Nothing . P.ProperName
117notQualified = P.Qualified Nothing . P.ProperName