Portability | portable |
---|---|
Stability | none |
Maintainer | uzytkownik2@gmail.com |
This module contains the common features and common interface.
- data Article = Article {}
- data Group = Group {}
- data NntpConnection m = NntpConnection {
- input :: ByteString
- output :: ByteString -> m ()
- data NntpState m = NntpState {
- connection :: NntpConnection m
- newtype NntpT m a = NntpT {}
- data NntpError
- runNntpWithHost :: MonadIO m => String -> Maybe Word16 -> (Bool -> NntpT m a) -> m (Either NntpError a)
- runNntpWithConnection :: Monad m => NntpConnection m -> (Bool -> NntpT m a) -> m (Either NntpError a)
- articleFromID :: Monad m => String -> NntpT m (Maybe Article)
- articleFromNo :: Monad m => Group -> Integer -> NntpT m (Maybe Article)
- groupFromName :: Monad m => String -> NntpT m (Maybe Group)
- forGroups :: Monad m => (Group -> m a) -> NntpT m [a]
- forNewGroups :: Monad m => UTCTime -> (Group -> m a) -> NntpT m [a]
- forArticles :: Monad m => Group -> (Article -> m a) -> NntpT m [a]
- forNewArticles :: Monad m => UTCTime -> Group -> (Article -> m a) -> NntpT m [a]
- fetchArticle :: Monad m => Article -> NntpT m Article
- fetchArticleHeader :: Monad m => Article -> NntpT m Article
- fetchArticleBody :: Monad m => Article -> NntpT m Article
- fetchArticleLazy :: Monad m => Article -> NntpT m Article
- fetchArticleHeaderLazy :: Monad m => Article -> NntpT m Article
- fetchArticleBodyLazy :: Monad m => Article -> NntpT m Article
- fetchGroup :: Monad m => Group -> NntpT m Group
- post :: Monad m => ByteString -> NntpT m ()
Types
Represents a single article. Please note that except the splitting into header and body no parsing is done.
Article | |
|
Represents a single group.
Group | |
|
data NntpConnection m Source
NntpConnection represents a connection in a NntpT monad.
Please note that for runNntpWithConnection
you need to supply both input
and output
functions.
NntpConnection | |
|
NntpState represents a state at given moment. Please note that this type is not a part of stable API (when we will have one).
NntpT represents a connection. Since some servers have short timeouts it is recommended to keep the connections short.
Errors
Indicates an error of handling NNTP connection. Please note that this should
indicate client errors only (with the exception of ServiceDiscontinued
,
in some cases PostingFailed
and NoSuchCommand
. The last one if propagated
outside NNTP module indicates a bug in library or server.).
NoSuchGroup | Indicates that operation was performed on group that does not exists. |
NoSuchArticle | Indicates that operation was performed on article that does not exists. |
PostingFailed | Indicates that posting operation failed for some reason. |
PostingNotAllowed | Indicates that posting is not allowed. |
ServiceDiscontinued | Indicates that service was discontinued. |
NoSuchCommand | Indicates that command does not exists. |
Functions
NntpState
-related functions
:: MonadIO m | |
=> String | A hostname. |
-> Maybe Word16 | Port. |
-> (Bool -> NntpT m a) | Function returning |
-> m (Either NntpError a) | Returned value. |
This is utility function which connects to a host, creates NntpState
and
supplies it to runNntpWithState
.
:: Monad m | |
=> NntpConnection m | A state |
-> (Bool -> NntpT m a) | Function returning |
-> m (Either NntpError a) | Returned value. |
Runs Nntp with given connection.
Commands functions
Returns the Article for given ID. Please note that it may or may not fetch the header and body. Preferred is lazy loading.
Returns the Article of given number from given Group. Please note that it may or may not fetch the header and body. Preferred is lazy loading.
Returns the Group of given name.
Iterates over every group on server collecting values. Please note that the function may be called before all I/O operations finished and the implementation may or may not allaw to call other NNTP functions during the call.
:: Monad m | |
=> UTCTime | Groups only newer thet this time will be returned. |
-> (Group -> m a) | Function called each time. |
-> NntpT m [a] | Collected values. |
Iterates over new group on server collecting values. Please note that the function may be called before all I/O operations finished and the implementation may or may not allaw to call other NNTP functions during the call.
:: Monad m | |
=> Group | Group which we iterate. |
-> (Article -> m a) | Function called each time. |
-> NntpT m [a] | Collected values. |
Iterates over the articles in group collecting values. Please note that the function may be called before all I/O operations finished and the implementation may or may not allaw to call other NNTP functions during the call.
:: Monad m | |
=> UTCTime | Articles only newer thet this time will be returned. |
-> Group | Group which we iterate. |
-> (Article -> m a) | Function called each time. |
-> NntpT m [a] | Collected values. |
Iterates over the new articles in group collecting values. Please note that the function may be called before all I/O operations finished and the implementation may or may not allaw to call other NNTP functions during the call.
Fetch the article.
Fetch the article header.
Fetch the article header.
Fetchs the article only if it is not fetched.
Fetchs the article header if it is not fetched.
Fetchs the article body if it is not fetched.