#ifdef LIFT_COMPAT
#else
#endif
module URI.ByteString.Types where
import Data.ByteString (ByteString)
import qualified Data.Map.Strict as M
import Data.Monoid
import Data.Semigroup (Semigroup)
import Data.Typeable
import Data.Word
import GHC.Generics
import Instances.TH.Lift()
import Prelude
#ifdef LIFT_COMPAT
import Language.Haskell.TH.Syntax()
import Language.Haskell.TH.Lift
#else
import Language.Haskell.TH.Syntax
#endif
newtype Scheme = Scheme { schemeBS :: ByteString }
deriving (Show, Eq, Generic, Typeable, Ord)
#ifdef LIFT_COMPAT
deriveLift ''Scheme
#else
deriving instance Lift Scheme
#endif
newtype Host = Host { hostBS :: ByteString }
deriving (Show, Eq, Generic, Typeable, Ord)
#ifdef LIFT_COMPAT
deriveLift ''Host
#else
deriving instance Lift Host
#endif
newtype Port = Port { portNumber :: Int }
deriving (Show, Eq, Generic, Typeable, Ord)
#ifdef LIFT_COMPAT
deriveLift ''Port
#else
deriving instance Lift Port
#endif
data UserInfo = UserInfo {
uiUsername :: ByteString
, uiPassword :: ByteString
} deriving (Show, Eq, Generic, Typeable, Ord)
#ifdef LIFT_COMPAT
deriveLift ''UserInfo
#else
deriving instance Lift UserInfo
#endif
data Authority = Authority {
authorityUserInfo :: Maybe UserInfo
, authorityHost :: Host
, authorityPort :: Maybe Port
} deriving (Show, Eq, Generic, Typeable, Ord)
#ifdef LIFT_COMPAT
deriveLift ''Authority
#else
deriving instance Lift Authority
#endif
newtype Query = Query { queryPairs :: [(ByteString, ByteString)] }
deriving (Show, Eq, Semigroup, Monoid, Generic, Typeable, Ord)
#ifdef LIFT_COMPAT
deriveLift ''Query
#else
deriving instance Lift Query
#endif
data Absolute deriving(Typeable)
#ifdef LIFT_COMPAT
deriveLift ''Absolute
#else
deriving instance Lift Absolute
#endif
data Relative deriving(Typeable)
#ifdef LIFT_COMPAT
deriveLift ''Relative
#else
deriving instance Lift Relative
#endif
data URIRef a where
URI :: { uriScheme :: Scheme
, uriAuthority :: Maybe Authority
, uriPath :: ByteString
, uriQuery :: Query
, uriFragment :: Maybe ByteString
} -> URIRef Absolute
RelativeRef :: { rrAuthority :: Maybe Authority
, rrPath :: ByteString
, rrQuery :: Query
, rrFragment :: Maybe ByteString
} -> URIRef Relative
deriving instance Show (URIRef a)
deriving instance Eq (URIRef a)
deriving instance Ord (URIRef a)
#ifdef LIFT_COMPAT
deriveLift ''URIRef
#else
deriving instance Lift (URIRef a)
#endif
#ifdef WITH_TYPEABLE
deriving instance Typeable URIRef
#endif
type URI = URIRef Absolute
type RelativeRef = URIRef Relative
data URIParserOptions = URIParserOptions {
upoValidQueryChar :: Word8 -> Bool
}
data URINormalizationOptions = URINormalizationOptions {
unoDowncaseScheme :: Bool
, unoDowncaseHost :: Bool
, unoDropDefPort :: Bool
, unoSlashEmptyPath :: Bool
, unoDropExtraSlashes :: Bool
, unoSortParameters :: Bool
, unoRemoveDotSegments :: Bool
, unoDefaultPorts :: M.Map Scheme Port
} deriving (Show, Eq)
data SchemaError = NonAlphaLeading
| InvalidChars
| MissingColon
deriving (Show, Eq, Read, Generic, Typeable)
data URIParseError = MalformedScheme SchemaError
| MalformedUserInfo
| MalformedQuery
| MalformedFragment
| MalformedHost
| MalformedPort
| MalformedPath
| OtherError String
deriving (Show, Eq, Generic, Read, Typeable)