Skip to content

Instantly share code, notes, and snippets.

@cocreature
Created June 14, 2017 16:38
Show Gist options
  • Save cocreature/a60028c3f6c3bf6d1c306f1a797355df to your computer and use it in GitHub Desktop.
Save cocreature/a60028c3f6c3bf6d1c306f1a797355df to your computer and use it in GitHub Desktop.
{-# 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