| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
| Extensions |
|
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:
, 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.)Params, the constraints the methods require. For instance, aCstrtConnectionusing real network operations would likely haveMonadIOas a constraint.- Implementations for
open,close,send,recvandupgrade. These are typically very thin wrappers around the operations provided by a network library.
Synopsis
- class Connection c where
- withConnection :: (MonadMask m, Cstrt c m, Connection c) => Params c -> (c -> m b) -> m b
Documentation
class Connection c where Source #
Class for abstract connections over some
transport channel c.
Associated Types
type Cstrt c :: (* -> *) -> Constraint Source #
Constraints an implementation must satisfy.
(e.g., MonadIO for network-based connections.)
Parameters used to create a connection -- e.g. hostname, port, TLS settings, etc.
Methods
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.