module Cryptsy.API.Public.Types.MarketData
( module Cryptsy.API.Public.Types.MarketData
, module Cryptsy.API.Public.Types.Market
, module Cryptsy.API.Public.Types.Num
, module Cryptsy.API.Public.Types.Time
)
where
import Data.Aeson (FromJSON(..), Value, withObject )
import Data.Aeson.Types (Parser)
import Data.Function (($))
import Data.Functor (fmap, (<$>))
import Data.Traversable (mapM)
import Prelude (Show(show))
import Data.Text (Text)
import Data.HashMap.Strict (HashMap)
import Cryptsy.API.Public.Types.Market
import Cryptsy.API.Public.Types.Num
import Cryptsy.API.Public.Types.Time
newtype GMarketData p q dt t =
MarketData { markets :: HashMap Text (GMarket p q dt t) }
deriving Show
type MarketData = GMarketData CryptsyNum CryptsyNum CryptsyTime CryptsyNum
instance FromJSON (GMarket p q dt t) => FromJSON (GMarketData p q dt t) where
parseJSON = parseMarketData parseJSON
parseMarketData :: (Value -> Parser (GMarket p q dt t))
-> Value -> Parser (GMarketData p q dt t)
parseMarketData parseSingle =
withObject "MarketData" $ fmap MarketData <$> mapM parseSingle