reddit-0.2.2.2: Library for interfacing with Reddit's API

Safe HaskellNone
LanguageHaskell2010

Reddit

Contents

Description

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.

Synopsis

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 #

Run a Reddit or RedditT 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 Reddit sessions or use a custom user agent string.

runResumeRedditWith :: MonadIO m => RedditOptions -> RedditT m a -> m (Either (APIError RedditError, Maybe (RedditT m a)) a) Source #

Run a Reddit or RedditT 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 Reddit sessions or use a custom user agent string.

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.

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?

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

Re-exports

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) 

Methods

(==) :: APIError a -> APIError a -> Bool #

(/=) :: APIError a -> APIError a -> Bool #

Show a => Show (APIError a) 

Methods

showsPrec :: Int -> APIError a -> ShowS #

show :: APIError a -> String #

showList :: [APIError a] -> ShowS #

Monoid (APIError a) 

Methods

mempty :: APIError a #

mappend :: APIError a -> APIError a -> APIError a #

mconcat :: [APIError a] -> APIError a #