URI.hs 713 B

1234567891011121314151617181920212223
  1. {-# LANGUAGE OverloadedStrings #-}
  2. module Data.SMTP.Types.URI where
  3. import Data.SMTP.Account
  4. import qualified Data.ByteString as BS
  5. import Text.StringConvert
  6. newtype Path = Path FilePath deriving (Eq, Ord, Read, Show)
  7. newtype Revision = Revision String deriving (Eq, Ord, Read, Show)
  8. data URI = URI {account :: Account, path :: Path, revision :: Maybe Revision}
  9. deriving (Eq, Ord, Read)
  10. fullURI :: URI -> BS.ByteString
  11. fullURI (URI a (Path p) r) = let bg = BS.concat ["FCMTP://", fullAccount a, s p]
  12. in case r of
  13. Nothing -> bg
  14. Just (Revision r') -> BS.concat[bg, "#", s r']
  15. instance Show URI where
  16. show = toString . fullURI