The code below generates orphan instances for store
. It works fine for aeson 1.4.7.1
but generates error in aeson 2.0.3.0
.
{-# LANGUAGE DeriveDataTypeable,DeriveGeneric,TemplateHaskell,GeneralizedNewtypeDeriving, OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
import Data.Store (Store)
import TH.Derive
import Data.Scientific
import Data.Aeson (Value)
-- This will allow us to serialize Aeson objects
$($(derive [d| instance Deriving (Store (Scientific)) |]))
$($(derive [d| instance Deriving (Store (Value)) |])) -- Template haskell derivation of Store instance for Value
With aeson 2.0.3.0
(as listed in stackage LTS-20.13
- working code was compiled using LTS-16.31
with store 0.7.1
and aeson 1.4.7.1
), it now throws errors about some store instance missing for aeson internal object - top level error below:
No instance for (Store
aeson-2.0.3.0:Data.Aeson.Types.Internal.Object)
arising from a use of ‘store-0.7.16:Data.Store.Impl.size’
Will appreciate pointers on how to fix this.
Update
Added the following template haskell derivations (along with ScopedTypeVariable
pragma to compile) following suggestions of @daniel-wagner:
$($(derive [d| instance Deriving (Store (Key)) |]))
$($(derive [d|
instance Store a => Deriving (Store (KeyMap a))
|]))