I am getting this error:
No instance for (Show (ClientM Bittrex)) arising from a use of ‘print
While building the following code:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
module Main where
import Data.Aeson
import Data.Proxy
import GHC.Generics
import Network.HTTP.Client (newManager, defaultManagerSettings)
import Servant.API
import Servant.Client
data Bittrex = Bittrex
{ success :: Bool,
message :: String,
result :: Inner
} deriving (Generic, Show)
instance FromJSON Bittrex
instance ToJSON Bittrex
data Inner = Inner
{ bid :: Float,
ask :: Float,
last :: Float
} deriving (Generic, Show)
instance FromJSON Inner
instance ToJSON Inner
--------------------------------------------------------------------------------
-- https://bittrex.com/api/v1.1/public/getticker?market=BTC-LTC
type BittrexAPI = "api" :> "v1.1" :> "public" :> "getticker?market=BTC-LTC" :> Get '[JSON] Bittrex
-----------------------------------------------------------------------------
bittrexAPI :: Proxy BittrexAPI
bittrexAPI = Proxy
bittrex = client bittrexAPI
main :: IO ()
main = do
manager <- newManager defaultManagerSettings
res <- runClientM bittrex (ClientEnv manager (BaseUrl Http "bittrex.com" 80 ""))
case res of
Left err -> putStrLn $ "Error: " ++ show err
Right test -> do
print $ bittrex
I know the problem is coming from the fact that I have a JSON response with embedded JSON. I'm not sure how to rectify this or more importantly why this is happening. The request link is https://bittrex.com/api/v1.1/public/getticker?market=BTC-LTC