URI.hs 706 B

123456789101112131415161718192021222324252627
  1. {-# LANGUAGE OverloadedStrings #-}
  2. module Data.SMTP.Types.URI where
  3. import Data.SMTP.Account
  4. import Data.List
  5. import Text.StringConvert
  6. newtype Path = Path [String] 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. fullPath :: URI -> String
  11. fullPath URI{path=Path p} = "/" ++ intercalate "/" p
  12. fullURI :: URI -> String
  13. fullURI u@(URI{account=a, revision=r}) =
  14. concat $ ["FCMTP://", s . fullAccount $ a, fullPath u] ++
  15. case r of
  16. Nothing -> []
  17. Just (Revision r') -> [":", r']
  18. instance Show URI where
  19. show = toString . fullURI