intolerable/reddit

Option limit doesn't do anything

Closed this issue · 1 comments

{-# LANGUAGE OverloadedStrings #-}
module Lib where
    -- ( someFunc
    -- ) where

import Reddit
import Reddit.Types.SearchOptions (Order(..))
import Reddit.Types.Post
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Monoid

findHaskellPosts :: RedditT IO PostListing
findHaskellPosts = search (Just $ R "programming") (Options Nothing (Just 0)) Hot "haskell"

printHaskellPosts :: IO ()
printHaskellPosts = do
  posts <- runRedditAnon findHaskellPosts
  case posts of
    Right posts' ->
      T.putStrLn (T.intercalate "\n\n". map printPost $ contents posts')
    Left _ -> T.putStrLn "No posts found matching 'haskell'"

printPost :: Post -> T.Text
printPost post = do
  title post <> "\n" <> (T.pack . show . created $ post) <> "\n" <> "http://reddit.com" <> permalink post

Limit doesn't seem to do anything:

λ> fmap (length . contents) <$> (runRedditAnon $ search (Just $ R "programming") (Options Nothing Nothing) Hot "haskell")
Right 25
λ> fmap (length . contents) <$> (runRedditAnon $ search (Just $ R "programming") (Options Nothing (Just 1)) Hot "haskell")
Right 25
λ> fmap (length . contents) <$> (runRedditAnon $ search (Just $ R "programming") (Options Nothing (Just 1000000)) Hot "haskell")
Right 25
λ> fmap (length . contents) <$> (runRedditAnon $ search (Just $ R "programming") (Options Nothing (Just 0)) Hot "haskell")
Right 25

thanks