nntp-0.0.4: Library to connect to an NNTP Server

Portabilityportable
Stabilitynone
Maintaineruzytkownik2@gmail.com

Network.NNTP

Contents

Description

This module contains the common features and common interface.

Synopsis

Types

data Article Source

Represents a single article. Please note that except the splitting into header and body no parsing is done.

Constructors

Article 

Fields

articleID :: String

Returns the article ID

articleHeader :: Maybe ByteString

Returns the article header. Data.Maybe.Nothing indicates not fetched header.

articleBody :: Maybe ByteString

Returns the article body. Data.Maybe.Nothing indicates not fetched body.

Instances

data Group Source

Represents a single group.

Constructors

Group 

Fields

groupName :: String

Returns the group name.

groupArticleFirst :: Integer

Returns the number of first article avaible.

groupArticleLast :: Integer

Returns the number of last article avaible.

Instances

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.

Constructors

NntpConnection 

Fields

input :: ByteString

Input is an stream which is from a server.

output :: ByteString -> m ()

Output is a function which sends the data to a server.

data NntpState m Source

NntpState represents a state at given moment. Please note that this type is not a part of stable API (when we will have one).

Constructors

NntpState 

newtype NntpT m a Source

NntpT represents a connection. Since some servers have short timeouts it is recommended to keep the connections short.

Constructors

NntpT 

Fields

runNntpT :: NntpState m -> m (NntpState m, Either NntpError a)
 

Instances

Errors

data NntpError Source

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

Constructors

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

runNntpWithHostSource

Arguments

:: MonadIO m 
=> String

A hostname.

-> Maybe Word16

Port. Nothing for standard port.

-> (Bool -> NntpT m a)

Function returning NntpT monad. Argument indicates if posting is allowed.

-> m (Either NntpError a)

Returned value.

This is utility function which connects to a host, creates NntpState and supplies it to runNntpWithState.

runNntpWithConnectionSource

Arguments

:: Monad m 
=> NntpConnection m

A state

-> (Bool -> NntpT m a)

Function returning NntpT monad. Argument indicates if posting is allowed.

-> m (Either NntpError a)

Returned value.

Runs Nntp with given connection.

Commands functions

articleFromIDSource

Arguments

:: Monad m 
=> String

ID of article.

-> NntpT m (Maybe Article)

Returns the article.

Returns the Article for given ID. Please note that it may or may not fetch the header and body. Preferred is lazy loading.

articleFromNoSource

Arguments

:: Monad m 
=> Group

Group.

-> Integer

ID of article.

-> NntpT m (Maybe Article)

Returns the article.

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.

groupFromNameSource

Arguments

:: Monad m 
=> String

Name of group.

-> NntpT m (Maybe Group)

Group.

Returns the Group of given name.

forGroupsSource

Arguments

:: Monad m 
=> (Group -> m a)

Function called each time.

-> NntpT m [a]

Collected values.

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.

forNewGroupsSource

Arguments

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

forArticlesSource

Arguments

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

forNewArticlesSource

Arguments

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

fetchArticleSource

Arguments

:: Monad m 
=> Article

An article.

-> NntpT m Article

Updated article.

Fetch the article.

fetchArticleHeaderSource

Arguments

:: Monad m 
=> Article

An article.

-> NntpT m Article

Updated article.

Fetch the article header.

fetchArticleBodySource

Arguments

:: Monad m 
=> Article

An article.

-> NntpT m Article

Updated article.

Fetch the article header.

fetchArticleLazySource

Arguments

:: Monad m 
=> Article

An article.

-> NntpT m Article

Updated article.

Fetchs the article only if it is not fetched.

fetchArticleHeaderLazySource

Arguments

:: Monad m 
=> Article

An article.

-> NntpT m Article

Updated article.

Fetchs the article header if it is not fetched.

fetchArticleBodyLazySource

Arguments

:: Monad m 
=> Article

An article.

-> NntpT m Article

Updated article.

Fetchs the article body if it is not fetched.

fetchGroupSource

Arguments

:: Monad m 
=> Group

A group.

-> NntpT m Group

Updated group.

Updates group.

postSource

Arguments

:: Monad m 
=> ByteString

Article contents

-> NntpT m () 

Posts an article.