Created
January 16, 2020 23:26
-
-
Save hasufell/dfeefb652e58ad1db560df64857299af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module Types.JSON where | |
import Data.Aeson | |
import Data.Aeson.TH | |
import Data.Aeson.Types | |
instance (ToJSON a, ToJSONKey a) => ToJSONKey (Maybe a) where | |
toJSONKey = genericToJSONKey defaultJSONKeyOptions | |
instance (FromJSON a, FromJSONKey a) => FromJSONKey (Maybe a) where | |
fromJSONKey = genericFromJSONKey defaultJSONKeyOptions | |
{- | |
lib/Types/JSON.hs:62:17: error: | |
• Could not deduce (aeson-1.4.6.0:Data.Aeson.Types.FromJSON.SumFromString | |
(GHC.Generics.M1 | |
GHC.Generics.C | |
('GHC.Generics.MetaCons "Just" 'GHC.Generics.PrefixI 'False) | |
(GHC.Generics.S1 | |
('GHC.Generics.MetaSel | |
'Nothing | |
'GHC.Generics.NoSourceUnpackedness | |
'GHC.Generics.NoSourceStrictness | |
'GHC.Generics.DecidedLazy) | |
(GHC.Generics.Rec0 a)))) | |
arising from a use of ‘genericFromJSONKey’ | |
from the context: (FromJSON a, FromJSONKey a) | |
bound by the instance declaration | |
at lib/Types/JSON.hs:61:10-61 | |
• In the expression: genericFromJSONKey defaultJSONKeyOptions | |
In an equation for ‘fromJSONKey’: | |
fromJSONKey = genericFromJSONKey defaultJSONKeyOptions | |
In the instance declaration for ‘FromJSONKey (Maybe a)’ | |
| | |
62 | fromJSONKey = genericFromJSONKey defaultJSONKeyOptions | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment