reddit
reddit copied to clipboard
Example is not working
Example from readme:
{-# LANGUAGE OverloadedStrings #-}
import Reddit
import Reddit.Types.Post
import Control.Monad
import Control.Monad.IO.Class
import Data.Monoid
import qualified Data.Text as Text
import qualified Data.Text.IO as Text
main = runRedditAnon $ do
Listing _ _ posts <- getPosts
forM_ posts $ \post -> do
liftIO $ Text.putStrLn $
"[" <> tshow (score post) <> "] " <>
title post <> " (" <> tshow (subreddit post) <> ")"
tshow = Text.pack . show
fails to compile:
• Couldn't match expected type ‘Integer’
with actual type ‘SubredditName’
• In the first argument of ‘tshow’, namely ‘(subreddit post)’
In the first argument of ‘(<>)’, namely ‘tshow (subreddit post)’
In the second argument of ‘(<>)’, namely
‘tshow (subreddit post) <> ")"’
|
23 | title post <> " (" <> tshow (subreddit post) <> ")"
| ^^^^^^^^^^^^^^
Adding signature to tshow fixed it for me:
tshow :: Show a => a -> Text.Text