@@ -80,11 +80,17 @@ import Streamly.Internal.Data.Unbox.TH (DataCon(..))
80-- no inline specific pragma let's GHC decide whether to put the code in
80-- no inline specific pragma let's GHC decide whether to put the code in
81-- interface file or not.
81-- interface file or not.
83−-- | Configuration to control how the 'Serialize' instance is generated. Use
83+-- | Configuration to control how the 'Serialize' instance is generated. The
84−-- 'serializeConfig' and config setter functions to generate desired Config. For
84+-- configuration is opaque and is modified by composing config modifier
85−-- example:
85+-- functions, for example:
87−-- >>> (inlineAddSizeTo (Just Inline)) . (inlineSerializeAt (Just Inlinable)) serializeConfig
87+-- >>> (inlineSerializeAt (Just NoInline)) . (inlineSerializeAt (Just Inlinable))
89+-- The default configuration settings are:
91+-- * 'inlineAddSizeTo' Nothing
92+-- * 'inlineSerializeAt' (Just Inline)
93+-- * 'inlineDeserializeAt' (Just Inline)
89data SerializeConfig =
95data SerializeConfig =
90 SerializeConfig
96 SerializeConfig
@@ -95,19 +101,19 @@ data SerializeConfig =
95 , cfgRecordSyntaxWithHeader :: Bool
101 , cfgRecordSyntaxWithHeader :: Bool
98−-- | How should we inline the 'addSizeTo' function? The default in 'serializeConfig'
104+-- | How should we inline the 'addSizeTo' function? The default is 'Nothing'
99−-- is 'Nothing' which means left to the compiler. Forcing inline on @addSizeTo@
105+-- which means left to the compiler. Forcing inline on @addSizeTo@ function
100−-- function actually worsens some benchmarks and improves none.
106+-- actually worsens some benchmarks and improves none.
101inlineAddSizeTo :: Maybe Inline -> SerializeConfig -> SerializeConfig
107inlineAddSizeTo :: Maybe Inline -> SerializeConfig -> SerializeConfig
102inlineAddSizeTo v cfg = cfg {cfgInlineSize = v}
108inlineAddSizeTo v cfg = cfg {cfgInlineSize = v}
104-- XXX Should we make the default Inlinable instead?
110-- XXX Should we make the default Inlinable instead?
106−-- | How should we inline the 'serialize' function? The default in
112+-- | How should we inline the 'serialize' function? The default 'Just Inline'.
107−-- 'serializeConfig' is 'Just Inline'. However, aggressive inlining can bloat
113+-- However, aggressive inlining can bloat the code and increase in compilation
108−-- the code and increase in compilation times when there are big functions and
114+-- times when there are big functions and too many nesting levels so you can
109−-- too many nesting levels so you can change it accordingly. A 'Nothing' value
115+-- change it accordingly. A 'Nothing' value leaves the decision to the
110−-- leaves the decision to the compiler.
116+-- compiler.
111inlineSerializeAt :: Maybe Inline -> SerializeConfig -> SerializeConfig
117inlineSerializeAt :: Maybe Inline -> SerializeConfig -> SerializeConfig
112inlineSerializeAt v cfg = cfg {cfgInlineSerialize = v}
118inlineSerializeAt v cfg = cfg {cfgInlineSerialize = v}
@@ -182,12 +188,6 @@ encodeConstrNames v cfg = cfg {cfgConstructorTagAsString = v}
182encodeRecordFields :: Bool -> SerializeConfig -> SerializeConfig
188encodeRecordFields :: Bool -> SerializeConfig -> SerializeConfig
183encodeRecordFields v cfg = cfg {cfgRecordSyntaxWithHeader = v}
189encodeRecordFields v cfg = cfg {cfgRecordSyntaxWithHeader = v}
185−-- | The default configuration settings are:
187−-- * 'inlineAddSizeTo' 'Nothing'
188−-- * 'inlineSerializeAt' (Just Inline)
189−-- * 'inlineDeserializeAt' (Just Inline)
191serializeConfig :: SerializeConfig
191serializeConfig :: SerializeConfig
192serializeConfig =
192serializeConfig =
193 SerializeConfig
193 SerializeConfig