Giter Site home page Giter Site logo

reddit's Introduction

reddit for haskell

A Haskell library for interacting with the Reddit API. Requires api-builder, but you will probably have to install it from the repository, because it needs a newer version than the one that's on Hackage.

### Basic usage

Almost everything is inside the Reddit monad, which handles errors and rate limiting (if you use runRedditWithRateLimiting) for you seamlessly – you can run the Reddit monad with runReddit user pass, which logs you in, grabs a token and starts running your actions.

Most of the time you can get away with importing Reddit.API and Reddit.API.Types and most of the stuff is available from there.

Here are some examples of functions that are useful:

getPostInfo :: PostID -> Reddit Post
getPosts :: SubredditName -> Reddit PostListing
savePost :: PostID -> Reddit ()
deletePost :: PostID -> Reddit ()

Most of the functions available have prime (') versions which accept extra options (before, after and limit api params).

For example, getPosts :: SubredditName -> Reddit PostListing corresponds to getPosts' :: Options PostID -> ListingType -> SubredditName -> Reddit PostListing, and most other functions follow this pattern.

Testing

The test test suite will run the tests that don't rely on doing any IO, but the test-io should be used too to ensure that IO functions do what they're supposed to do. If you want to run the IO suite, add a file test.cfg to the reddit/ directory, containing (one field per line):

  • a reddit username
  • a reddit password
  • a subreddit name (the user should be a moderator for the subredit)

Run cabal test test-io and the tests should pass.

reddit's People

Contributors

intolerable avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar Tiago Elias Vicente avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.