jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.89k stars 3.39k forks source link

Move `toJsonFilter` to a special `Text.Pandoc.JSON` module in `pandoc-types`. #928

Closed jgm closed 11 years ago

jgm commented 11 years ago

This would really reduce executable sizes in scripts.

jgm commented 11 years ago

Perhaps custom ToJSON and FromJSON instances should be added as well, in this module, rather than relying on slow generics.

jgm commented 11 years ago

Or maybe use GHC generics, since we have instances for pandoc anyway?

Use DeriveGeneric pragma, and just:

instance FromJSON Pandoc
instance ToJSON Pandoc
jgm commented 11 years ago

With this approach we'd need:

instance FromJSON MetaValue
instance ToJSON MetaValue

instance FromJSON Meta
instance ToJSON Meta

instance FromJSON CitationMode
instance ToJSON CitationMode

instance FromJSON Citation
instance ToJSON Citation

instance FromJSON QuoteType
instance ToJSON QuoteType

instance FromJSON MathType
instance ToJSON MathType

instance FromJSON ListNumberStyle
instance ToJSON ListNumberStyle

instance FromJSON ListNumberDelim
instance ToJSON ListNumberDelim

instance FromJSON Alignment
instance ToJSON Alignment

instance FromJSON Inline
instance ToJSON Inline

instance FromJSON Block
instance ToJSON Block

instance FromJSON Pandoc
instance ToJSON Pandoc

Some benchmarks suggest that using GHC generics is significantly faster than using the syb generics as we currently do (> 2x writing, slightly less reading).

jgm commented 11 years ago

Done 1567d291a3aed0e55ddaaa65492ab19741e515b5