assumpta-core-0.1.0.2: Core functionality for an SMTP client

Network.Mail.Assumpta.Connection

Description

Class using type families to represent abstract connection types that (in addition to the usual network operations) can be upgraded from insecure to secure.

Any instance must specify:

• Params, the type of parameters that can be used to open a connection. (This might be a just a tuple containing just hostname and port, say, or might be some more complicated structure.)
• Cstrt, the constraints the methods require. For instance, a Connection using real network operations would likely have MonadIO as a constraint.
• Implementations for open, close, send, recv and upgrade. These are typically very thin wrappers around the operations provided by a network library.
Synopsis

# Documentation

class Connection c where Source #

Class for abstract connections over some transport channel c.

Minimal complete definition

Associated Types

type Cstrt c :: (* -> *) -> Constraint Source #

Constraints an implementation must satisfy. (e.g., MonadIO for network-based connections.)

type Params c :: * Source #

Parameters used to create a connection -- e.g. hostname, port, TLS settings, etc.

Methods

Arguments

 :: Cstrt c m => Params c -> m c open a connection

Arguments

 :: Cstrt c m => c -> m () close a connection

Arguments

 :: Cstrt c m => c -> ByteString -> m () send a bytestring

Arguments

 :: Cstrt c m => c -> m ByteString receive a bytestring

Arguments

 :: Cstrt c m => c -> m () upgrade security

withConnection :: (MonadMask m, Cstrt c m, Connection c) => Params c -> (c -> m b) -> m b Source #

withConnection p a

bracket for Connections. Given some parameters p for opening a connection: open a connection, run some action a with it, then close.