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

Safe HaskellSafe
LanguageHaskell2010
Extensions
  • MonoLocalBinds
  • TypeFamilies
  • ConstraintKinds
  • KindSignatures
  • ExplicitNamespaces

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

open, close, send, recv, upgrade

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

open Source #

Arguments

:: Cstrt c m 
=> Params c 
-> m c

open a connection

close Source #

Arguments

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

close a connection

send Source #

Arguments

:: Cstrt c m 
=> c 
-> ByteString 
-> m ()

send a bytestring

recv Source #

Arguments

:: Cstrt c m 
=> c 
-> m ByteString

receive a bytestring

upgrade Source #

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.