Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module should be most of what you need to operate the library.
It exports functionality for running built RedditT
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 Reddit.Types.*
qualified so that you can use all
the record fields without having to deal with ambiguous functions.
- runReddit :: MonadIO m => Text -> Text -> RedditT m a -> m (Either (APIError RedditError) a)
- runRedditAnon :: MonadIO m => RedditT m a -> m (Either (APIError RedditError) a)
- runRedditWith :: MonadIO m => RedditOptions -> RedditT m a -> m (Either (APIError RedditError) a)
- runResumeRedditWith :: MonadIO m => RedditOptions -> RedditT m a -> m (Either (APIError RedditError, Maybe (RedditT m a)) a)
- interpretIO :: MonadIO m => RedditState -> RedditT m a -> m (Either (APIError RedditError, Maybe (RedditT m a)) a)
- data RedditOptions = RedditOptions {}
- defaultRedditOptions :: RedditOptions
- data LoginMethod
- data APIError a :: * -> *
- module Reddit.Actions
- module Reddit.Types
- module Reddit.Types.Error
- module Reddit.Types.Reddit
Documentation
runReddit :: MonadIO m => Text -> Text -> RedditT m a -> m (Either (APIError RedditError) a) Source #
Run a Reddit
action (or a RedditT
transformer action). This uses the default logged-in settings
for RedditOptions
: 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 Reddit's API policy says that you should have a uniquely identifiable user agent.
runRedditAnon :: MonadIO m => RedditT m a -> m (Either (APIError RedditError) a) Source #
Run a Reddit
action (or a RedditT
transformer action). This uses the default logged-out settings, so
you won't be able to do anything that requires authentication (like checking messages or making a post).
At the moment, authentication isn't statically checked, so it'll return a runtime error if you try to do
anything you don't have permissions for.
runRedditWith :: MonadIO m => RedditOptions -> RedditT m a -> m (Either (APIError RedditError) a) Source #
runResumeRedditWith :: MonadIO m => RedditOptions -> RedditT m a -> m (Either (APIError RedditError, Maybe (RedditT m a)) a) Source #
interpretIO :: MonadIO m => RedditState -> RedditT m a -> m (Either (APIError RedditError, Maybe (RedditT m a)) a) Source #
data RedditOptions Source #
Options for how we should run the Reddit
action.
rateLimitingEnabled
:True
if the connection should be automatically rate-limited and should pause when we hit the limit,False
otherwise. Default isTrue
.connectionManager
:
if the connection should use theJust
xManager
x
,Nothing
if we should create a new one for the connection. Default isNothing
.loginMethod
: The method we should use for authentication, described inLoginMethod
. Default isAnonymous
.customUserAgent
:
if the connection should use the user agentJust
"string""string"
,
if it should use the default agent. Default isNothing
Nothing
.
defaultRedditOptions :: RedditOptions Source #
The default set of options
data LoginMethod Source #
Should we log in to Reddit? If so, 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 |
Re-exports
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. |
module Reddit.Actions
module Reddit.Types
module Reddit.Types.Error
module Reddit.Types.Reddit