on master help sign in
Fix #290: Remove MINIMAL pragma for toJSON

We would like to set the MINIMAL pragma for toJSON but then instances which are using the default Generic implementation will complain that toJSON is not defined. This is caused by a bug in GHC: https://ghc.haskell.org/trac/ghc/ticket/10959

commitf3fce247bfcfcbd6faa984696f24c5c5fc4f44de authorBas van Dijk <v.dijk.bas@gmail.com> dateSun 11 Oct 2015, 16:00 (11 years ago) parent25df642
1 file changed+6−1
Data/Aeson/Types/Class.hs+6−1
Data/Aeson/Types/Class.hs+6−1
@@ -135,7 +135,12 @@ genericParseJSON opts = fmap to . gParseJSON opts
135135class ToJSON a where
136136 -- | Convert a Haskell value to a JSON-friendly intermediate type.
137137 toJSON :: a -> Value
138− {-# MINIMAL toJSON #-}
138+
139+ -- TODO: We would like to set the MINIMAL pragma for toJSON but then
140+ -- instances which are using the default Generic implementation will
141+ -- complain that toJSON is not defined.
142+ -- See GHC bug: https://ghc.haskell.org/trac/ghc/ticket/10959
143+ -- {-# MINIMAL toJSON -- #-}
139144
140145 default toJSON :: (Generic a, GToJSON (Rep a)) => a -> Value
141146 toJSON = genericToJSON defaultOptions