discogs-haskell-0.0.5.0: Client for Discogs REST API

Safe HaskellNone
LanguageHaskell2010

Discogs

Description

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.

Synopsis

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

Run a Discogs action (or a DiscogsT transformer action). This uses the default logged-out settings, so you won't be able to do anything that requires authentication (like searching or marketplace related functions).

runResumeDiscogsWith :: MonadIO m => DiscogsOptions -> DiscogsT m a -> m (Either (APIError DiscogsError, Maybe (DiscogsT m a)) a) Source

Run a Discogs or DiscogsT action with custom settings. You probably won't need this function for most things, but it's handy if you want to persist a connection over multiple Discogs sessions or use a custom user agent string.

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?

Constructors

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 runDiscogsAnon $ login user pass.

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.

Constructors

APIError a

A type that represents any error that happens on the API end. Define your own custom type with a FromJSON instance if you want to handle them, or you can use () if you just want to ignore them all.

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 Builder's base URL and your Routes.

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.

Instances

Eq a => Eq (APIError a) 
Show a => Show (APIError a) 
Monoid (APIError a) 

data DiscogsF m a where Source

Constructors

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 

Instances