-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | stats.NBA.com library
--   
--   Functions and types for interacting with stats.NBA.com
@package kawhi
@version 0.3.0


-- | Class, instances and transformer for monads capable of HTTP requests.
--   
--   In some cases, it is useful to generalize this capability. For
--   example, it can be used provide mock responses for testing.
module Control.Monad.Http

-- | The class of monads capable of HTTP requests.
class Monad m => MonadHttp m
performRequest :: MonadHttp m => Request -> m (Response ByteString)

-- | An HTTP transformer monad parameterized by an inner monad <tt>m</tt>.
newtype HttpT m a
HttpT :: ReaderT (Response ByteString) m a -> HttpT m a
[unHttpT] :: HttpT m a -> ReaderT (Response ByteString) m a

-- | Run an HTTP monad action and extract the inner monad.
runHttpT :: HttpT m a -> Response ByteString -> m a
instance GHC.Base.Monad m => Control.Monad.Reader.Class.MonadReader (Network.HTTP.Client.Types.Response Data.ByteString.Lazy.Internal.ByteString) (Control.Monad.Http.HttpT m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Http.HttpT m)
instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Control.Monad.Http.HttpT m)
instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Control.Monad.Http.HttpT m)
instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Http.HttpT
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Http.HttpT m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Http.HttpT m)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Http.HttpT m)
instance Control.Monad.Catch.MonadThrow m => Control.Monad.Http.MonadHttp (Control.Monad.Http.HttpT m)
instance Control.Monad.Error.Class.MonadError e m => Control.Monad.Error.Class.MonadError e (Control.Monad.Http.HttpT m)
instance Control.Monad.Http.MonadHttp GHC.Types.IO
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.Http.MonadHttp (Control.Monad.Trans.Except.ExceptT e m)


-- | Functions and types for interacting with <a>NBA Stats</a>.
module Data.NBA.Stats

-- | Gets all the rows in a NBA Stats split.
--   
--   To retrieve the raw data from NBA Stats independently from parsing,
--   use <a>splitRows</a>.
--   
--   When using this function in a custom monad transformer, it may be
--   desirable to use the generic version of this function,
--   <a>getSplitRowsGeneric</a>, instead.
getSplitRows :: FromJSON a => StatsPath -> SplitName -> StatsParameters -> IO (Either StatsError [a])

-- | Gets a row in a NBA Stats split.
--   
--   To retrieve the raw data from NBA Stats independently from parsing,
--   use <a>splitRows</a>.
--   
--   When using this function in a custom monad transformer, it may be
--   desirable to use the generic version of this function,
--   <a>getSplitRowGeneric</a>, instead.
getSplitRow :: (Eq v, Show v, FromJSON v, FromJSON a) => StatsPath -> SplitName -> SplitColumn -> v -> StatsParameters -> IO (Either StatsError a)

-- | Parses all the rows of an NBA Stats split from abitrary data.
--   
--   Alternatively, <a>getSplitRows</a> retrieves the data from NBA Stats
--   before parsing.
--   
--   To use something other than <a>Either</a> for errors, use the generic
--   version of this function, <a>splitRowsGeneric</a>, instead.
splitRows :: FromJSON a => SplitName -> StatsBytes -> Either StatsError [a]

-- | Parses a row of an NBA Stats split from abitrary data.
--   
--   Alternatively, <a>getSplitRow</a> retrieves the data from NBA Stats
--   before parsing.
--   
--   To use something other than <a>Either</a> for errors, use the generic
--   version of this function, <a>splitRowGeneric</a>, instead.
splitRow :: (Eq v, Show v, FromJSON v, FromJSON a) => SplitName -> SplitColumn -> v -> StatsBytes -> Either StatsError a

-- | Gets all the rows in a NBA Stats split.
--   
--   To retrieve the raw data from NBA Stats independently from parsing,
--   use <a>splitRowsGeneric</a>.
--   
--   The simpler version of this function, <a>getSplitRows</a>, has a
--   concrete <tt>m</tt>.
getSplitRowsGeneric :: (MonadIO m, MonadHttp m, MonadError StatsError m, MonadThrow m, FromJSON a) => StatsPath -> SplitName -> StatsParameters -> m [a]

-- | Gets a row in an NBA Stats split.
--   
--   To retrieve the raw data from NBA Stats independently from parsing,
--   use <a>splitRowGeneric</a>.
--   
--   The simpler version of this function, <a>getSplitRows</a>, has a
--   concrete <tt>m</tt>.
getSplitRowGeneric :: (MonadIO m, MonadHttp m, MonadError StatsError m, MonadThrow m, Eq v, Show v, FromJSON v, FromJSON a) => StatsPath -> SplitName -> SplitColumn -> v -> StatsParameters -> m a

-- | Parses all the rows of an NBA Stats split from abitrary data.
--   
--   Alternatively, <a>getSplitRowsGeneric</a> retrieves the data from NBA
--   Stats before parsing.
splitRowsGeneric :: (MonadError StatsError m, FromJSON a) => SplitName -> StatsBytes -> m [a]

-- | Parses a row of an NBA Stats split from abitrary data.
--   
--   Alternatively, <a>getSplitRowGeneric</a> retrieves the data from NBA
--   Stats before parsing.
splitRowGeneric :: (MonadError StatsError m, Eq v, Show v, FromJSON v, FromJSON a) => SplitName -> SplitColumn -> v -> StatsBytes -> m a

-- | An NBA Stats resource.
--   
--   This type represents the top-level JSON object returned from the NBA
--   Stats REST API.
data Stats

-- | Constructor for stats resource.
Stats :: [Split] -> Stats

-- | The resource's splits.
[splits] :: Stats -> [Split]

-- | An NBA Stats split.
--   
--   This type represents splits available from NBA Stats.
data Split

-- | Constructor for a split.
Split :: SplitName -> [SplitColumn] -> [SplitRow] -> Split

-- | The split's name.
[name] :: Split -> SplitName

-- | The split's column names.
[columns] :: Split -> [SplitColumn]

-- | The split's rows of data.
[rows] :: Split -> [SplitRow]

-- | An NBA Stats split name.
type SplitName = Text

-- | A column name in an NBA Stats split.
type SplitColumn = Text

-- | A row of data in an NBA Stats split.
type SplitRow = [Value]

-- | A URL path for an NBA Stats resource.
type StatsPath = ByteString

-- | A collection of parameters that customize NBA Stats resources.
type StatsParameters = [(ByteString, Maybe ByteString)]

-- | Bytes representing an NBA Stats resource.
type StatsBytes = ByteString

-- | An error which may be generated by this library.
data StatsError

-- | An HTTP response has invalid JSON.
StatsResponseDecodeFailure :: String -> StatsError

-- | A stats resource does not have a split matching the given split name.
SplitNameNotFound :: String -> StatsError

-- | A split does not have a row matching the given column key and row
--   value.
SplitKeyNotFound :: String -> StatsError

-- | A split row has a different cardinality than the associated columns.
SplitRowCardinalityInconsistent :: String -> StatsError

-- | A split does not have a column name matching the given key.
SplitColumnNameNotFound :: String -> StatsError

-- | A failure to parse a split row's tabular data to the destination type.
SplitRowParseFailure :: String -> StatsError
instance GHC.Classes.Eq Data.NBA.Stats.StatsError
instance GHC.Classes.Eq Data.NBA.Stats.Stats
instance GHC.Show.Show Data.NBA.Stats.Stats
instance GHC.Classes.Eq Data.NBA.Stats.Split
instance GHC.Show.Show Data.NBA.Stats.Split
instance GHC.Show.Show Data.NBA.Stats.StatsError
instance Data.Aeson.Types.ToJSON.ToJSON Data.NBA.Stats.Stats
instance Data.Aeson.Types.FromJSON.FromJSON Data.NBA.Stats.Stats
instance Data.Aeson.Types.FromJSON.FromJSON Data.NBA.Stats.Split
instance Data.Aeson.Types.ToJSON.ToJSON Data.NBA.Stats.Split
