@@ -5,7 +5,10 @@ module Language.PureScript.Docs.RenderedCode.Render (
55 renderType,
66 renderTypeAtom,
77 renderRow,
8− renderKind
8+ renderKind,
9+ RenderTypeOptions(..),
10+ defaultRenderTypeOptions,
11+ renderTypeWithOptions
912) where
1013
1114import Data.Monoid ((<>), mconcat, mempty)
@@ -119,9 +122,9 @@ forall_ = mkPattern match
119122 match (PrettyPrintForAll idents ty) = Just (idents, ty)
120123 match _ = Nothing
121124
122−insertPlaceholders :: Type -> Type
123−insertPlaceholders =
124− everywhereOnTypesTopDown convertForAlls . everywhereOnTypes convert
125+insertPlaceholders :: RenderTypeOptions -> Type -> Type
126+insertPlaceholders opts =
127+ everywhereOnTypesTopDown convertForAlls . everywhereOnTypes (convert opts)
125128
126129dePrim :: Type -> Type
127130dePrim ty@(TypeConstructor (Qualified _ name))
@@ -129,10 +132,10 @@ dePrim ty@(TypeConstructor (Qualified _ name))
129132 TypeConstructor $ Qualified Nothing name
130133dePrim other = other
131134
132−convert :: Type -> Type
133−convert (TypeApp (TypeApp f arg) ret) | f == tyFunction = PrettyPrintFunction arg ret
134−convert (TypeApp o r) | o == tyObject = PrettyPrintObject r
135−convert other = other
135+convert :: RenderTypeOptions -> Type -> Type
136+convert _ (TypeApp (TypeApp f arg) ret) | f == tyFunction = PrettyPrintFunction arg ret
137+convert opts (TypeApp o r) | o == tyObject && prettyPrintObjects opts = PrettyPrintObject r
138+convert _ other = other
136139
137140convertForAlls :: Type -> Type
138141convertForAlls (ForAll i ty _) = go [i] ty
@@ -141,8 +144,8 @@ convertForAlls (ForAll i ty _) = go [i] ty
141144 go idents other = PrettyPrintForAll idents other
142145convertForAlls other = other
143146
144−preprocessType :: Type -> Type
145−preprocessType = dePrim . insertPlaceholders
147+preprocessType :: RenderTypeOptions -> Type -> Type
148+preprocessType opts = dePrim . insertPlaceholders opts
146149
147150-- |
148151-- Render code representing a Kind
@@ -154,12 +157,23 @@ renderKind = kind . prettyPrintKind
154157-- Render code representing a Type, as it should appear inside parentheses
155158--
156159renderTypeAtom :: Type -> RenderedCode
157−renderTypeAtom = fromMaybe (error "Incomplete pattern") . pattern matchTypeAtom () . preprocessType
160+renderTypeAtom =
161+ fromMaybe (error "Incomplete pattern") . pattern matchTypeAtom () . preprocessType defaultRenderTypeOptions
158162
159163
160164-- |
161165-- Render code representing a Type
162166--
163167renderType :: Type -> RenderedCode
164−renderType = fromMaybe (error "Incomplete pattern") . pattern matchType () . preprocessType
168+renderType = renderTypeWithOptions defaultRenderTypeOptions
165169
170+data RenderTypeOptions = RenderTypeOptions
171+ { prettyPrintObjects :: Bool
172+ }
173+
174+defaultRenderTypeOptions :: RenderTypeOptions
175+defaultRenderTypeOptions = RenderTypeOptions { prettyPrintObjects = True }
176+
177+renderTypeWithOptions :: RenderTypeOptions -> Type -> RenderedCode
178+renderTypeWithOptions opts =
179+ fromMaybe (error "Incomplete pattern") . pattern matchType () . preprocessType opts