Safe Haskell | None |
---|---|
Language | Haskell2010 |
This main module contains the building blocks to operate the library.
It exports functionality for running built DiscogsT
actions, as well
as re-exporting a few helpful types from around the library. Not every
type is exported, however, due to clashing record fields. It's recommended
to import modules from Discogs.Types.*
qualified so that you can use all
the record fields without having to deal with ambiguous functions.
- runDiscogs :: MonadIO m => Text -> Text -> DiscogsT m a -> m (Either (APIError DiscogsError) a)
- runDiscogsAnon :: MonadIO m => DiscogsT m a -> m (Either (APIError DiscogsError) a)
- runDiscogsWith :: MonadIO m => DiscogsOptions -> DiscogsT m a -> m (Either (APIError DiscogsError) a)
- runResumeDiscogsWith :: MonadIO m => DiscogsOptions -> DiscogsT m a -> m (Either (APIError DiscogsError, Maybe (DiscogsT m a)) a)
- interpretIO :: MonadIO m => DiscogsState -> DiscogsT m a -> m (Either (APIError DiscogsError, Maybe (DiscogsT m a)) a)
- data DiscogsOptions = DiscogsOptions {}
- defaultDiscogsOptions :: DiscogsOptions
- data LoginMethod
- data APIError a :: * -> *
- data DiscogsError
- type Discogs a = DiscogsT IO a
- newtype DiscogsT m a = DiscogsT (FreeT (DiscogsF m) m a)
- data DiscogsF m a where
- FailWith :: APIError DiscogsError -> DiscogsF m a
- Nest :: DiscogsT m b -> (Either (APIError DiscogsError) b -> a) -> DiscogsF m a
- NestResuming :: DiscogsT m b -> (Either (APIError DiscogsError, Maybe (DiscogsT m b)) b -> a) -> DiscogsF m a
- ReceiveRoute :: Receivable b => Route -> (b -> a) -> DiscogsF m a
- RunRoute :: FromJSON b => Route -> (b -> a) -> DiscogsF m a
- WithBaseURL :: Text -> DiscogsT m b -> (b -> a) -> DiscogsF m a
- runRoute :: (FromJSON a, Monad m) => Route -> DiscogsT m a
- receiveRoute :: (Receivable a, Monad m) => Route -> DiscogsT m a
- nest :: Monad m => DiscogsT m a -> DiscogsT m (Either (APIError DiscogsError) a)
- failWith :: Monad m => APIError DiscogsError -> DiscogsT m a
- newtype Modhash = Modhash Text
- data LoginDetails = LoginDetails Modhash CookieJar
- withBaseURL :: Monad m => Text -> DiscogsT m a -> DiscogsT m a
- builder :: Builder
- mainBaseURL :: Text
- loginBaseURL :: Text
- addHeader :: Maybe ByteString -> Request -> Request
- addAPIType :: Route -> Route
Documentation
runDiscogs :: MonadIO m => Text -> Text -> DiscogsT m a -> m (Either (APIError DiscogsError) a) Source
Run a Discogs
action (or a DiscogsT
transformer action). This uses the default logged-in settings
for DiscogsOptions
: rate limiting enabled, default manager, login via username and password, and
the default user-agent. You should change the user agent if you're making anything more complex than
a basic script, since Discogs's API policy says that you should have a uniquely identifiable user agent.
runDiscogsAnon :: MonadIO m => DiscogsT m a -> m (Either (APIError DiscogsError) a) Source
runDiscogsWith :: MonadIO m => DiscogsOptions -> DiscogsT m a -> m (Either (APIError DiscogsError) a) Source
runResumeDiscogsWith :: MonadIO m => DiscogsOptions -> DiscogsT m a -> m (Either (APIError DiscogsError, Maybe (DiscogsT m a)) a) Source
interpretIO :: MonadIO m => DiscogsState -> DiscogsT m a -> m (Either (APIError DiscogsError, Maybe (DiscogsT m a)) a) Source
defaultDiscogsOptions :: DiscogsOptions Source
The default set of options (ie: Anonymous login)
data LoginMethod Source
Are we logging in to Discogs? If yes, should we use a stored set of credentials or get a new fresh set?
Anonymous | Don't login, instead use an anonymous account |
Credentials Text Text | Login using the specified username and password |
StoredDetails LoginDetails | Login using a stored set of credentials. Usually the best way to get
these is to do |
data APIError a :: * -> *
Error type for the API
, where a
is the type that should be returned when
something goes wrong on the other end - i.e. any error that isn't directly related
to this library.
APIError a | A type that represents any error that happens on the API end.
Define your own custom type with a |
HTTPError HttpException | Something went wrong when we tried to do a HTTP operation. |
InvalidURLError | You're trying to create an invalid URL somewhere - check your
|
ParseError String | Failed when parsing the response, and it wasn't an error on their end. |
EmptyError | Empty error to serve as a zero element for Monoid. |
data DiscogsError Source
data DiscogsF m a where Source
FailWith :: APIError DiscogsError -> DiscogsF m a | |
Nest :: DiscogsT m b -> (Either (APIError DiscogsError) b -> a) -> DiscogsF m a | |
NestResuming :: DiscogsT m b -> (Either (APIError DiscogsError, Maybe (DiscogsT m b)) b -> a) -> DiscogsF m a | |
ReceiveRoute :: Receivable b => Route -> (b -> a) -> DiscogsF m a | |
RunRoute :: FromJSON b => Route -> (b -> a) -> DiscogsF m a | |
WithBaseURL :: Text -> DiscogsT m b -> (b -> a) -> DiscogsF m a |
receiveRoute :: (Receivable a, Monad m) => Route -> DiscogsT m a Source
data LoginDetails Source
addAPIType :: Route -> Route Source