{-# LANGUAGE OverloadedStrings #-} module Data.SMTP.Types.Address where import qualified Data.SMTP.Account as Ac import qualified Data.SMTP.URI as URI import qualified Data.SMTP.Seal as Seal import Data.ByteString (ByteString) import qualified Data.ByteString as BS data Address = Address {uri :: Maybe URI.URI, account :: Ac.Account, seal :: Maybe Seal.Seal} deriving (Read, Show, Eq, Ord) asToURI :: Address -> ByteString asToURI a@Address{uri = Nothing} = BS.concat ["<", Ac.normalize . account $ a, ">"] asToURI Address{uri = (Just u)} = URI.fullURI u hostFrom :: Address -> Ac.HostName hostFrom = Ac.domain . account fromAccount :: Ac.Account -> Address fromAccount a = Address Nothing a Nothing