git.iko.soy/typeable/pandoc
on master help sign in
Remove derive_json_via_th flag; always use TH.
8fb9a0dJohn MacFarlane
pandoc.cabal+1−9
@@ -359,11 +359,6 @@ flag embed_data_files
359 Description: Embed data files in binary for relocatable executable.
359 Description: Embed data files in binary for relocatable executable.
360 Default: False
360 Default: False
361
361
362−flag derive_json_via_th
363− Description: Use Template Haskell instead of GHC Generics to derive ToJSON
364− and FromJSON instances.
365− Default: False
366−
367flag trypandoc
362flag trypandoc
368 Description: Build trypandoc cgi executable.
363 Description: Build trypandoc cgi executable.
369 Default: False
364 Default: False
@@ -441,9 +436,6 @@ library
441 cpp-options: -DEMBED_DATA_FILES
436 cpp-options: -DEMBED_DATA_FILES
442 build-depends: file-embed >= 0.0 && < 0.1
437 build-depends: file-embed >= 0.0 && < 0.1
443 other-modules: Text.Pandoc.Data
438 other-modules: Text.Pandoc.Data
444− if flag(derive_json_via_th)
445− cpp-options: -DDERIVE_JSON_VIA_TH
446− other-extensions: TemplateHaskell
447 if os(windows)
439 if os(windows)
448 cpp-options: -D_WINDOWS
440 cpp-options: -D_WINDOWS
449 ghc-options: -Wall -fno-warn-unused-do-bind
441 ghc-options: -Wall -fno-warn-unused-do-bind
@@ -462,7 +454,7 @@ library
462 -fhide-source-paths
454 -fhide-source-paths
463
455
464 default-language: Haskell2010
456 default-language: Haskell2010
465− other-extensions: NoImplicitPrelude
457+ other-extensions: NoImplicitPrelude, TemplateHaskell
466 hs-source-dirs: src
458 hs-source-dirs: src
467
459
468 exposed-modules: Text.Pandoc,
460 exposed-modules: Text.Pandoc,
src/Text/Pandoc/App/CommandLineOptions.hs−3
@@ -2,9 +2,6 @@
2{-# LANGUAGE CPP #-}
2{-# LANGUAGE CPP #-}
3{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4{-# LANGUAGE TupleSections #-}
4{-# LANGUAGE TupleSections #-}
5−#ifdef DERIVE_JSON_VIA_TH
6−{-# LANGUAGE TemplateHaskell #-}
7−#endif
8{- |
5{- |
9 Module : Text.Pandoc.App.CommandLineOptions
6 Module : Text.Pandoc.App.CommandLineOptions
10 Copyright : Copyright (C) 2006-2019 John MacFarlane
7 Copyright : Copyright (C) 2006-2019 John MacFarlane
src/Text/Pandoc/App/Opt.hs−14
@@ -2,9 +2,7 @@
2{-# LANGUAGE NoImplicitPrelude #-}
2{-# LANGUAGE NoImplicitPrelude #-}
3{-# LANGUAGE CPP #-}
3{-# LANGUAGE CPP #-}
4{-# LANGUAGE DeriveGeneric #-}
4{-# LANGUAGE DeriveGeneric #-}
5−#ifdef DERIVE_JSON_VIA_TH
6{-# LANGUAGE TemplateHaskell #-}
5{-# LANGUAGE TemplateHaskell #-}
7−#endif
8{- |
6{- |
9 Module : Text.Pandoc.App.Opt
7 Module : Text.Pandoc.App.Opt
10 Copyright : Copyright (C) 2006-2019 John MacFarlane
8 Copyright : Copyright (C) 2006-2019 John MacFarlane
@@ -36,11 +34,7 @@ import qualified Data.Text as T
36import Data.Aeson (defaultOptions, Options(..), FromJSON(..), ToJSON(..),
34import Data.Aeson (defaultOptions, Options(..), FromJSON(..), ToJSON(..),
37 Value(..))
35 Value(..))
38import Data.Aeson.Types (typeMismatch)
36import Data.Aeson.Types (typeMismatch)
39−#ifdef DERIVE_JSON_VIA_TH
40import Data.Aeson.TH (deriveJSON)
37import Data.Aeson.TH (deriveJSON)
41−#else
42−import Data.Aeson (genericToEncoding)
43−#endif
44
38
45-- | The type of line-endings to be used when writing plain-text.
39-- | The type of line-endings to be used when writing plain-text.
46data LineEnding = LF | CRLF | Native deriving (Show, Generic)
40data LineEnding = LF | CRLF | Native deriving (Show, Generic)
@@ -203,16 +197,8 @@ defaultOpts = Opt
203 , optStripComments = False
197 , optStripComments = False
204 }
198 }
205
199
206−#ifdef DERIVE_JSON_VIA_TH
207-- see https://github.com/jgm/pandoc/pull/4083
200-- see https://github.com/jgm/pandoc/pull/4083
208-- using generic deriving caused long compilation times
201-- using generic deriving caused long compilation times
209$(deriveJSON
202$(deriveJSON
210 defaultOptions{ fieldLabelModifier =
203 defaultOptions{ fieldLabelModifier =
211 camelCaseToHyphenated . drop 3 } ''Opt)
204 camelCaseToHyphenated . drop 3 } ''Opt)
212−#else
213−instance ToJSON Opt where
214− toEncoding = genericToEncoding
215− defaultOptions{ fieldLabelModifier =
216− camelCaseToHyphenated . drop 3 }
217−instance FromJSON Opt
218−#endif
src/Text/Pandoc/Extensions.hs−18
@@ -2,10 +2,8 @@
2{-# LANGUAGE NoImplicitPrelude #-}
2{-# LANGUAGE NoImplicitPrelude #-}
3{-# LANGUAGE DeriveDataTypeable #-}
3{-# LANGUAGE DeriveDataTypeable #-}
4{-# LANGUAGE DeriveGeneric #-}
4{-# LANGUAGE DeriveGeneric #-}
5−#ifdef DERIVE_JSON_VIA_TH
6{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving #-}
7{-# LANGUAGE TemplateHaskell #-}
6{-# LANGUAGE TemplateHaskell #-}
8−#endif
9{- |
7{- |
10 Module : Text.Pandoc.Extensions
8 Module : Text.Pandoc.Extensions
11 Copyright : Copyright (C) 2012-2019 John MacFarlane
9 Copyright : Copyright (C) 2012-2019 John MacFarlane
@@ -41,13 +39,7 @@ import Data.Typeable (Typeable)
41import GHC.Generics (Generic)
39import GHC.Generics (Generic)
42import Safe (readMay)
40import Safe (readMay)
43import Text.Parsec
41import Text.Parsec
44−
45−#ifdef DERIVE_JSON_VIA_TH
46import Data.Aeson.TH (deriveJSON, defaultOptions)
42import Data.Aeson.TH (deriveJSON, defaultOptions)
47−#else
48−import Data.Aeson (FromJSON (..), ToJSON (..),
49− defaultOptions, genericToEncoding)
50−#endif
51
43
52newtype Extensions = Extensions Integer
44newtype Extensions = Extensions Integer
53 deriving (Show, Read, Eq, Ord, Data, Typeable, Generic)
45 deriving (Show, Read, Eq, Ord, Data, Typeable, Generic)
@@ -538,15 +530,5 @@ parseFormatSpec = parse formatSpec ""
538 '+' -> (ext : extsToEnable, extsToDisable)
530 '+' -> (ext : extsToEnable, extsToDisable)
539 _ -> (extsToEnable, ext : extsToDisable)
531 _ -> (extsToEnable, ext : extsToDisable)
540
532
541−#ifdef DERIVE_JSON_VIA_TH
542$(deriveJSON defaultOptions ''Extension)
533$(deriveJSON defaultOptions ''Extension)
543$(deriveJSON defaultOptions ''Extensions)
534$(deriveJSON defaultOptions ''Extensions)
544−#else
545−instance ToJSON Extension where
546− toEncoding = genericToEncoding defaultOptions
547−instance FromJSON Extension
548−
549−instance ToJSON Extensions where
550− toEncoding = genericToEncoding defaultOptions
551−instance FromJSON Extensions
552−#endif
src/Text/Pandoc/Filter.hs−13
@@ -1,9 +1,7 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE NoImplicitPrelude #-}
3{-# LANGUAGE NoImplicitPrelude #-}
4−#ifdef DERIVE_JSON_VIA_TH
5{-# LANGUAGE TemplateHaskell #-}
4{-# LANGUAGE TemplateHaskell #-}
6−#endif
7{- |
5{- |
8 Module : Text.Pandoc.Filter
6 Module : Text.Pandoc.Filter
9 Copyright : Copyright (C) 2006-2019 John MacFarlane
7 Copyright : Copyright (C) 2006-2019 John MacFarlane
@@ -21,12 +19,7 @@ module Text.Pandoc.Filter
21 ) where
19 ) where
22
20
23import Prelude
21import Prelude
24−#ifdef DERIVE_JSON_VIA_TH
25import Data.Aeson.TH (deriveJSON, defaultOptions)
22import Data.Aeson.TH (deriveJSON, defaultOptions)
26−#else
27−import Data.Aeson (FromJSON (..), ToJSON (..),
28− defaultOptions, genericToEncoding)
29−#endif
30import Data.Foldable (foldrM)
23import Data.Foldable (foldrM)
31import GHC.Generics (Generic)
24import GHC.Generics (Generic)
32import Text.Pandoc.Class (PandocIO)
25import Text.Pandoc.Class (PandocIO)
@@ -59,10 +52,4 @@ expandFilterPath :: Filter -> PandocIO Filter
59expandFilterPath (LuaFilter fp) = LuaFilter <$> Path.expandFilterPath fp
52expandFilterPath (LuaFilter fp) = LuaFilter <$> Path.expandFilterPath fp
60expandFilterPath (JSONFilter fp) = JSONFilter <$> Path.expandFilterPath fp
53expandFilterPath (JSONFilter fp) = JSONFilter <$> Path.expandFilterPath fp
61
54
62−#ifdef DERIVE_JSON_VIA_TH
63$(deriveJSON defaultOptions ''Filter)
55$(deriveJSON defaultOptions ''Filter)
64−#else
65−instance ToJSON Filter where
66− toEncoding = genericToEncoding defaultOptions
67−instance FromJSON Filter
68−#endif
src/Text/Pandoc/Options.hs−46
@@ -2,9 +2,7 @@
2{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveDataTypeable #-}
3{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE DeriveGeneric #-}
4{-# LANGUAGE NoImplicitPrelude #-}
4{-# LANGUAGE NoImplicitPrelude #-}
5−#ifdef DERIVE_JSON_VIA_TH
6{-# LANGUAGE TemplateHaskell #-}
5{-# LANGUAGE TemplateHaskell #-}
7−#endif
8{- |
6{- |
9 Module : Text.Pandoc.Options
7 Module : Text.Pandoc.Options
10 Copyright : Copyright (C) 2012-2019 John MacFarlane
8 Copyright : Copyright (C) 2012-2019 John MacFarlane
@@ -42,13 +40,7 @@ import Skylighting (SyntaxMap, defaultSyntaxMap)
42import Text.Pandoc.Extensions
40import Text.Pandoc.Extensions
43import Text.Pandoc.Highlighting (Style, pygments)
41import Text.Pandoc.Highlighting (Style, pygments)
44import Text.DocTemplates (Template)
42import Text.DocTemplates (Template)
45−
46−#ifdef DERIVE_JSON_VIA_TH
47import Data.Aeson.TH (deriveJSON, defaultOptions)
43import Data.Aeson.TH (deriveJSON, defaultOptions)
48−#else
49−import Data.Aeson (FromJSON (..), ToJSON (..),
50− defaultOptions, genericToEncoding)
51−#endif
52
44
53class HasSyntaxExtensions a where
45class HasSyntaxExtensions a where
54 getExtensions :: a -> Extensions
46 getExtensions :: a -> Extensions
@@ -230,7 +222,6 @@ instance HasSyntaxExtensions WriterOptions where
230isEnabled :: HasSyntaxExtensions a => Extension -> a -> Bool
222isEnabled :: HasSyntaxExtensions a => Extension -> a -> Bool
231isEnabled ext opts = ext `extensionEnabled` getExtensions opts
223isEnabled ext opts = ext `extensionEnabled` getExtensions opts
232
224
233−#ifdef DERIVE_JSON_VIA_TH
234$(deriveJSON defaultOptions ''ReaderOptions)
225$(deriveJSON defaultOptions ''ReaderOptions)
235$(deriveJSON defaultOptions ''HTMLMathMethod)
226$(deriveJSON defaultOptions ''HTMLMathMethod)
236$(deriveJSON defaultOptions ''CiteMethod)
227$(deriveJSON defaultOptions ''CiteMethod)
@@ -240,40 +231,3 @@ $(deriveJSON defaultOptions ''TrackChanges)
240$(deriveJSON defaultOptions ''WrapOption)
231$(deriveJSON defaultOptions ''WrapOption)
241$(deriveJSON defaultOptions ''TopLevelDivision)
232$(deriveJSON defaultOptions ''TopLevelDivision)
242$(deriveJSON defaultOptions ''ReferenceLocation)
233$(deriveJSON defaultOptions ''ReferenceLocation)
243−#else
244−instance ToJSON CiteMethod where
245− toEncoding = genericToEncoding defaultOptions
246−instance FromJSON CiteMethod
247−
248−instance ToJSON ReaderOptions where
249− toEncoding = genericToEncoding defaultOptions
250−instance FromJSON ReaderOptions
251−
252−instance ToJSON ObfuscationMethod where
253− toEncoding = genericToEncoding defaultOptions
254−instance FromJSON ObfuscationMethod
255−
256−instance ToJSON WrapOption where
257− toEncoding = genericToEncoding defaultOptions
258−instance FromJSON WrapOption
259−
260−instance ToJSON HTMLMathMethod where
261− toEncoding = genericToEncoding defaultOptions
262−instance FromJSON HTMLMathMethod
263−
264−instance ToJSON HTMLSlideVariant where
265− toEncoding = genericToEncoding defaultOptions
266−instance FromJSON HTMLSlideVariant
267−
268−instance ToJSON TopLevelDivision where
269− toEncoding = genericToEncoding defaultOptions
270−instance FromJSON TopLevelDivision
271−
272−instance ToJSON ReferenceLocation where
273− toEncoding = genericToEncoding defaultOptions
274−instance FromJSON ReferenceLocation
275−
276−instance ToJSON TrackChanges where
277− toEncoding = genericToEncoding defaultOptions
278−instance FromJSON TrackChanges
279−#endif
stack.yaml−1
@@ -2,7 +2,6 @@ flags:
2 pandoc:
2 pandoc:
3 trypandoc: false
3 trypandoc: false
4 embed_data_files: true
4 embed_data_files: true
5− derive_json_via_th: false
6 static: false
5 static: false
7 pandoc-citeproc:
6 pandoc-citeproc:
8 bibutils: true
7 bibutils: true