2

I still quite new to the whole monad/IO thing, and I am having trouble using the nntp package. Could someone show me an example of how to use it please? eg. How to get a list of article IDs of a group within the last 24 hours?

ePak
  • 484
  • 5
  • 12

1 Answers1

1

I'm not sure precisely which part of the problem you're stuck with (unless it's just "where the heck do I start?")

Looking at the documentation, it appears that the nntp package doesn't actually support header parsing, which seems bizarre. So you can ask it to fetch an article for you, but then you would have to figure out how to parse the headers to work out when the article was posted...

It looks like you can do something like

main = do
  articles <- runNntpWithHost "nntp.example.com" Nothing main2
  ...do stuff with articles...

main2 post_allowed = do
  group <- groupFromName "example.group"
  forArticles group return

to grab a list of all the articles in a given group. Not sure how you'd do anything more complex with this particular package...

MathematicalOrchid
  • 61,854
  • 19
  • 123
  • 220
  • I was a bit like "where the heck do I start?" at first, then I managed to get something similar to what you have shown me to compile. But when I ran it, it just sat there and not do anything. I know the server is active because it works if I do the same thing in python. Are you aware of any other nntp library in haskell? – ePak May 12 '13 at 12:03
  • @ePak I don't see anything else on Hackage, which is surprising. If you're running on Windows, you might need to call `withSocketsDo` to get network I/O to work. – MathematicalOrchid May 12 '13 at 21:22
  • Was doing this on a mac and tried it with `withSocketsDo`, still no luck. May be I will dig into the internal once I have gotten better with haskell. Thanks anyway. – ePak May 14 '13 at 03:29