Search code examples
haskellmonadsnntp

Seeking example of how to use nntp package


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?


Solution

  • 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...