getRateLimit :: Token -> IO (Result (Int, Int))
getRateLimit tok = do
    json <- callAPI GET tok "account/rate_limit_status" []
    return $
        case json of
            Ok (JSObject obj) -> (, ) <$> valFromObj "remaining_hits" obj <*> valFromObj "hourly_limit" obj
            Ok j              -> Error $ "invalid JSValue: " ++ show j
            -- to convert (Result JSValue) to (Result (Int, Int)),
            -- extract error message and re-wrap with Error.
            Error e           -> Error e


-- | call twitter API
-- callAPI GET tok "statuses/home_timeline" []
getRateLimit :: Token -> IO (Result (Int, Int))
getRateLimit tok = do
    json <- callAPI GET tok "account/rate_limit_status" []
    return $
        case json of
            Ok (JSObject obj) -> (, ) <$> valFromObj "remaining_hits" obj <*> valFromObj "hourly_limit" obj
            Ok j              -> Error $ "invalid JSValue: " ++ show j
            -- to convert (Result JSValue) to (Result (Int, Int)),
            -- extract error message and re-wrap with Error.
            Error e           -> Error e


-- | call twitter API
-- callAPI GET tok "statuses/home_timeline" []
getRateLimit tok = do
    json <- callAPI GET tok "account/rate_limit_status" []
    return $
        case json of
            Ok (JSObject obj) -> (, ) <$> valFromObj "remaining_hits" obj <*> valFromObj "hourly_limit" obj
            Ok j              -> Error $ "invalid JSValue: " ++ show j
            -- to convert (Result JSValue) to (Result (Int, Int)),
            -- extract error message and re-wrap with Error.
            Error e           -> Error e


-- | call twitter API
-- callAPI GET tok "statuses/home_timeline" []