Created
June 14, 2017 16:38
-
-
Save cocreature/a60028c3f6c3bf6d1c306f1a797355df 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 DeriveDataTypeable, DeriveGeneric, TupleSections #-} | |
import Data.Typeable | |
import Data.Aeson as Aeson | |
import Data.Text (Text) | |
import GHC.Generics | |
import qualified Data.HashMap.Lazy as LHM | |
newtype HStoreList = HStoreList {fromHStoreList :: [(Text,Text)]} deriving (Typeable, Eq, Show, Generic) | |
instance FromJSON HStoreList where | |
parseJSON = | |
withObject "Key-Value pair" $ \hm -> | |
HStoreList <$> (traverse (\(k, v) -> (k,) <$> withText "Text" pure v) (LHM.toList hm)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment