#if __GLASGOW_HASKELL__ < 800
{-# LANGUAGE RecordWildCards #-}
#endif
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 800
{-# LANGUAGE DeriveLift, StandaloneDeriving #-}
#else
{-# LANGUAGE TemplateHaskell #-}
#endif
#if MIN_VERSION_template_haskell(2,12,0) && MIN_VERSION_parsec(3,1,13)
{-# LANGUAGE Safe #-}
#elif __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
module Network.URI
(
URI(..)
, URIAuth(..)
, nullURI
, nullURIAuth
, rectify, rectifyAuth
, parseURI
, parseURIReference
, parseRelativeReference
, parseAbsoluteURI
, isURI
, isURIReference
, isRelativeReference
, isAbsoluteURI
, isIPv6address
, isIPv4address
, uriIsAbsolute
, uriIsRelative
, relativeTo
, nonStrictRelativeTo
, relativeFrom
, uriToString, uriAuthToString
, isReserved, isUnreserved
, isAllowedInURI, isUnescapedInURI
, isUnescapedInURIComponent
, escapeURIChar
, escapeURIString
, unEscapeString
, pathSegments
, normalizeCase
, normalizeEscape
, normalizePathSegments
, parseabsoluteURI
, escapeString
, reserved, unreserved
, scheme, authority, path, query, fragment
) where
import Text.ParserCombinators.Parsec
( GenParser, ParseError
, parse, (<?>), try
, option, many1, count, notFollowedBy
, char, satisfy, oneOf, string, eof
, unexpected
)
import Control.Applicative
import Control.Monad (MonadPlus(..))
import Control.DeepSeq (NFData(rnf), deepseq)
import Data.Char (ord, chr, isHexDigit, toLower, toUpper, digitToInt)
import Data.Bits ((.|.),(.&.),shiftL,shiftR)
import Data.List (unfoldr, isPrefixOf, isSuffixOf)
import Numeric (showIntAtBase)
import Language.Haskell.TH.Syntax (Lift(..))
#if !MIN_VERSION_base(4,8,0)
import Data.Traversable (sequenceA)
#endif
import Data.Typeable (Typeable)
#if MIN_VERSION_base(4,0,0)
import Data.Data (Data)
#else
import Data.Generics (Data)
#endif
#if __GLASGOW_HASKELL__ >= 702
import GHC.Generics (Generic)
#endif
data URI = URI
{ URI -> String
uriScheme :: String
, URI -> Maybe URIAuth
uriAuthority :: Maybe URIAuth
, URI -> String
uriPath :: String
, URI -> String
uriQuery :: String
, URI -> String
uriFragment :: String
#if __GLASGOW_HASKELL__ >= 702
} deriving (URI -> URI -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: URI -> URI -> Bool
$c/= :: URI -> URI -> Bool
== :: URI -> URI -> Bool
$c== :: URI -> URI -> Bool
Eq, Eq URI
URI -> URI -> Bool
URI -> URI -> Ordering
URI -> URI -> URI
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: URI -> URI -> URI
$cmin :: URI -> URI -> URI
max :: URI -> URI -> URI
$cmax :: URI -> URI -> URI
>= :: URI -> URI -> Bool
$c>= :: URI -> URI -> Bool
> :: URI -> URI -> Bool
$c> :: URI -> URI -> Bool
<= :: URI -> URI -> Bool
$c<= :: URI -> URI -> Bool
< :: URI -> URI -> Bool
$c< :: URI -> URI -> Bool
compare :: URI -> URI -> Ordering
$ccompare :: URI -> URI -> Ordering
Ord, Typeable, Typeable URI
URI -> DataType
URI -> Constr
(forall b. Data b => b -> b) -> URI -> URI
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> URI -> u
forall u. (forall d. Data d => d -> u) -> URI -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> URI -> m URI
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> URI -> m URI
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c URI
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> URI -> c URI
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c URI)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c URI)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> URI -> m URI
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> URI -> m URI
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> URI -> m URI
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> URI -> m URI
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> URI -> m URI
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> URI -> m URI
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> URI -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> URI -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> URI -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> URI -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r
gmapT :: (forall b. Data b => b -> b) -> URI -> URI
$cgmapT :: (forall b. Data b => b -> b) -> URI -> URI
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c URI)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c URI)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c URI)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c URI)
dataTypeOf :: URI -> DataType
$cdataTypeOf :: URI -> DataType
toConstr :: URI -> Constr
$ctoConstr :: URI -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c URI
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c URI
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> URI -> c URI
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> URI -> c URI
Data, forall x. Rep URI x -> URI
forall x. URI -> Rep URI x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep URI x -> URI
$cfrom :: forall x. URI -> Rep URI x
Generic)
#else
} deriving (Eq, Ord, Typeable, Data)
#endif
ensurePrefix :: String -> String -> String
ensurePrefix :: String -> String -> String
ensurePrefix String
p String
s = if String
p forall a. Eq a => [a] -> [a] -> Bool
`isPrefixOf` String
s then String
s else String
p forall a. [a] -> [a] -> [a]
++ String
s
ensureSuffix :: String -> String -> String
ensureSuffix :: String -> String -> String
ensureSuffix String
p String
s = if String
p forall a. Eq a => [a] -> [a] -> Bool
`isSuffixOf` String
s then String
s else String
s forall a. [a] -> [a] -> [a]
++ String
p
rectifyAuth :: URIAuth -> URIAuth
rectifyAuth :: URIAuth -> URIAuth
rectifyAuth URIAuth
a = URIAuth {
uriUserInfo :: String
uriUserInfo = forall a. ([a] -> [a]) -> [a] -> [a]
unlessEmpty (String -> String -> String
ensureSuffix String
"@") (URIAuth -> String
uriUserInfo URIAuth
a),
uriRegName :: String
uriRegName = URIAuth -> String
uriRegName URIAuth
a,
uriPort :: String
uriPort = forall a. ([a] -> [a]) -> [a] -> [a]
unlessEmpty (String -> String -> String
ensurePrefix String
":") (URIAuth -> String
uriPort URIAuth
a)
}
rectify :: URI -> URI
rectify :: URI -> URI
rectify URI
u = URI {
uriScheme :: String
uriScheme = String -> String -> String
ensureSuffix String
":" (URI -> String
uriScheme URI
u),
uriAuthority :: Maybe URIAuth
uriAuthority = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap URIAuth -> URIAuth
rectifyAuth (URI -> Maybe URIAuth
uriAuthority URI
u),
uriPath :: String
uriPath = URI -> String
uriPath URI
u,
uriQuery :: String
uriQuery = forall a. ([a] -> [a]) -> [a] -> [a]
unlessEmpty (String -> String -> String
ensurePrefix String
"?") (URI -> String
uriQuery URI
u),
uriFragment :: String
uriFragment = forall a. ([a] -> [a]) -> [a] -> [a]
unlessEmpty (String -> String -> String
ensurePrefix String
"#") (URI -> String
uriFragment URI
u)
}
unlessEmpty :: ([a] -> [a]) -> [a] -> [a]
unlessEmpty :: forall a. ([a] -> [a]) -> [a] -> [a]
unlessEmpty [a] -> [a]
_f [] = []
unlessEmpty [a] -> [a]
f [a]
x = [a] -> [a]
f [a]
x
instance NFData URI where
rnf :: URI -> ()
rnf (URI String
s Maybe URIAuth
a String
p String
q String
f)
= String
s forall a b. NFData a => a -> b -> b
`deepseq` Maybe URIAuth
a forall a b. NFData a => a -> b -> b
`deepseq` String
p forall a b. NFData a => a -> b -> b
`deepseq` String
q forall a b. NFData a => a -> b -> b
`deepseq` String
f forall a b. NFData a => a -> b -> b
`deepseq` ()
data URIAuth = URIAuth
{ URIAuth -> String
uriUserInfo :: String
, URIAuth -> String
uriRegName :: String
, URIAuth -> String
uriPort :: String
#if __GLASGOW_HASKELL__ >= 702
} deriving (URIAuth -> URIAuth -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: URIAuth -> URIAuth -> Bool
$c/= :: URIAuth -> URIAuth -> Bool
== :: URIAuth -> URIAuth -> Bool
$c== :: URIAuth -> URIAuth -> Bool
Eq, Eq URIAuth
URIAuth -> URIAuth -> Bool
URIAuth -> URIAuth -> Ordering
URIAuth -> URIAuth -> URIAuth
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: URIAuth -> URIAuth -> URIAuth
$cmin :: URIAuth -> URIAuth -> URIAuth
max :: URIAuth -> URIAuth -> URIAuth
$cmax :: URIAuth -> URIAuth -> URIAuth
>= :: URIAuth -> URIAuth -> Bool
$c>= :: URIAuth -> URIAuth -> Bool
> :: URIAuth -> URIAuth -> Bool
$c> :: URIAuth -> URIAuth -> Bool
<= :: URIAuth -> URIAuth -> Bool
$c<= :: URIAuth -> URIAuth -> Bool
< :: URIAuth -> URIAuth -> Bool
$c< :: URIAuth -> URIAuth -> Bool
compare :: URIAuth -> URIAuth -> Ordering
$ccompare :: URIAuth -> URIAuth -> Ordering
Ord, Int -> URIAuth -> String -> String
[URIAuth] -> String -> String
URIAuth -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [URIAuth] -> String -> String
$cshowList :: [URIAuth] -> String -> String
show :: URIAuth -> String
$cshow :: URIAuth -> String
showsPrec :: Int -> URIAuth -> String -> String
$cshowsPrec :: Int -> URIAuth -> String -> String
Show, Typeable, Typeable URIAuth
URIAuth -> DataType
URIAuth -> Constr
(forall b. Data b => b -> b) -> URIAuth -> URIAuth
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> URIAuth -> u
forall u. (forall d. Data d => d -> u) -> URIAuth -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> URIAuth -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> URIAuth -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> URIAuth -> m URIAuth
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> URIAuth -> m URIAuth
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c URIAuth
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> URIAuth -> c URIAuth
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c URIAuth)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c URIAuth)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> URIAuth -> m URIAuth
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> URIAuth -> m URIAuth
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> URIAuth -> m URIAuth
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> URIAuth -> m URIAuth
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> URIAuth -> m URIAuth
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> URIAuth -> m URIAuth
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> URIAuth -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> URIAuth -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> URIAuth -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> URIAuth -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> URIAuth -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> URIAuth -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> URIAuth -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> URIAuth -> r
gmapT :: (forall b. Data b => b -> b) -> URIAuth -> URIAuth
$cgmapT :: (forall b. Data b => b -> b) -> URIAuth -> URIAuth
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c URIAuth)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c URIAuth)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c URIAuth)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c URIAuth)
dataTypeOf :: URIAuth -> DataType
$cdataTypeOf :: URIAuth -> DataType
toConstr :: URIAuth -> Constr
$ctoConstr :: URIAuth -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c URIAuth
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c URIAuth
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> URIAuth -> c URIAuth
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> URIAuth -> c URIAuth
Data, forall x. Rep URIAuth x -> URIAuth
forall x. URIAuth -> Rep URIAuth x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep URIAuth x -> URIAuth
$cfrom :: forall x. URIAuth -> Rep URIAuth x
Generic)
#else
} deriving (Eq, Ord, Show, Typeable, Data)
#endif
instance NFData URIAuth where
rnf :: URIAuth -> ()
rnf (URIAuth String
ui String
rn String
p) = String
ui forall a b. NFData a => a -> b -> b
`deepseq` String
rn forall a b. NFData a => a -> b -> b
`deepseq` String
p forall a b. NFData a => a -> b -> b
`deepseq` ()
nullURI :: URI
nullURI :: URI
nullURI = URI
{ uriScheme :: String
uriScheme = String
""
, uriAuthority :: Maybe URIAuth
uriAuthority = forall a. Maybe a
Nothing
, uriPath :: String
uriPath = String
""
, uriQuery :: String
uriQuery = String
""
, uriFragment :: String
uriFragment = String
""
}
nullURIAuth :: URIAuth
nullURIAuth :: URIAuth
nullURIAuth = URIAuth
{ uriUserInfo :: String
uriUserInfo = String
""
, uriRegName :: String
uriRegName = String
""
, uriPort :: String
uriPort = String
""
}
instance Show URI where
showsPrec :: Int -> URI -> String -> String
showsPrec Int
_ = (String -> String) -> URI -> String -> String
uriToString String -> String
defaultUserInfoMap
defaultUserInfoMap :: String -> String
defaultUserInfoMap :: String -> String
defaultUserInfoMap String
uinf = String
userforall a. [a] -> [a] -> [a]
++String
newpass
where
(String
user,String
pass) = forall a. (a -> Bool) -> [a] -> ([a], [a])
break (forall a. Eq a => a -> a -> Bool
==Char
':') String
uinf
newpass :: String
newpass = if forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
pass Bool -> Bool -> Bool
|| (String
pass forall a. Eq a => a -> a -> Bool
== String
"@")
Bool -> Bool -> Bool
|| (String
pass forall a. Eq a => a -> a -> Bool
== String
":@")
then String
pass
else String
":...@"
parseURI :: String -> Maybe URI
parseURI :: String -> Maybe URI
parseURI = URIParser URI -> String -> Maybe URI
parseURIAny URIParser URI
uri
parseURIReference :: String -> Maybe URI
parseURIReference :: String -> Maybe URI
parseURIReference = URIParser URI -> String -> Maybe URI
parseURIAny URIParser URI
uriReference
parseRelativeReference :: String -> Maybe URI
parseRelativeReference :: String -> Maybe URI
parseRelativeReference = URIParser URI -> String -> Maybe URI
parseURIAny URIParser URI
relativeRef
parseAbsoluteURI :: String -> Maybe URI
parseAbsoluteURI :: String -> Maybe URI
parseAbsoluteURI = URIParser URI -> String -> Maybe URI
parseURIAny URIParser URI
absoluteURI
isURI :: String -> Bool
isURI :: String -> Bool
isURI = forall a. URIParser a -> String -> Bool
isValidParse URIParser URI
uri
isURIReference :: String -> Bool
isURIReference :: String -> Bool
isURIReference = forall a. URIParser a -> String -> Bool
isValidParse URIParser URI
uriReference
isRelativeReference :: String -> Bool
isRelativeReference :: String -> Bool
isRelativeReference = forall a. URIParser a -> String -> Bool
isValidParse URIParser URI
relativeRef
isAbsoluteURI :: String -> Bool
isAbsoluteURI :: String -> Bool
isAbsoluteURI = forall a. URIParser a -> String -> Bool
isValidParse URIParser URI
absoluteURI
isIPv6address :: String -> Bool
isIPv6address :: String -> Bool
isIPv6address = forall a. URIParser a -> String -> Bool
isValidParse URIParser String
ipv6address
isIPv4address :: String -> Bool
isIPv4address :: String -> Bool
isIPv4address = forall a. URIParser a -> String -> Bool
isValidParse URIParser String
ipv4address
parseURIAny :: URIParser URI -> String -> Maybe URI
parseURIAny :: URIParser URI -> String -> Maybe URI
parseURIAny URIParser URI
parser String
uristr = case forall a. URIParser a -> String -> String -> Either ParseError a
parseAll URIParser URI
parser String
"" String
uristr of
Left ParseError
_ -> forall a. Maybe a
Nothing
Right URI
u -> forall a. a -> Maybe a
Just URI
u
isValidParse :: URIParser a -> String -> Bool
isValidParse :: forall a. URIParser a -> String -> Bool
isValidParse URIParser a
parser String
uristr = case forall a. URIParser a -> String -> String -> Either ParseError a
parseAll URIParser a
parser String
"" String
uristr of
Left ParseError
_ -> Bool
False
Right a
_ -> Bool
True
parseAll :: URIParser a -> String -> String -> Either ParseError a
parseAll :: forall a. URIParser a -> String -> String -> Either ParseError a
parseAll URIParser a
parser String
filename String
uristr = forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
parse URIParser a
newparser String
filename String
uristr
where
newparser :: URIParser a
newparser =
do { a
result <- URIParser a
parser
; forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
; forall (m :: * -> *) a. Monad m => a -> m a
return a
result
}
uriIsAbsolute :: URI -> Bool
uriIsAbsolute :: URI -> Bool
uriIsAbsolute URI{uriScheme :: URI -> String
uriScheme = String
scheme'} = String
scheme' forall a. Eq a => a -> a -> Bool
/= String
""
uriIsRelative :: URI -> Bool
uriIsRelative :: URI -> Bool
uriIsRelative = Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. URI -> Bool
uriIsAbsolute
type URIParser a = GenParser Char () a
escaped :: URIParser String
escaped :: URIParser String
escaped = forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'%', ParsecT String () Identity Char
hexDigitChar, ParsecT String () Identity Char
hexDigitChar]
isReserved :: Char -> Bool
isReserved :: Char -> Bool
isReserved Char
c = Char -> Bool
isGenDelims Char
c Bool -> Bool -> Bool
|| Char -> Bool
isSubDelims Char
c
isGenDelims :: Char -> Bool
isGenDelims :: Char -> Bool
isGenDelims Char
c =
case Char
c of
Char
':' -> Bool
True
Char
'/' -> Bool
True
Char
'?' -> Bool
True
Char
'#' -> Bool
True
Char
'[' -> Bool
True
Char
']' -> Bool
True
Char
'@' -> Bool
True
Char
_ -> Bool
False
isSubDelims :: Char -> Bool
isSubDelims :: Char -> Bool
isSubDelims Char
c =
case Char
c of
Char
'!' -> Bool
True
Char
'$' -> Bool
True
Char
'&' -> Bool
True
Char
'\'' -> Bool
True
Char
'(' -> Bool
True
Char
')' -> Bool
True
Char
'*' -> Bool
True
Char
'+' -> Bool
True
Char
',' -> Bool
True
Char
';' -> Bool
True
Char
'=' -> Bool
True
Char
_ -> Bool
False
subDelims :: URIParser String
subDelims :: URIParser String
subDelims = (forall a. a -> [a] -> [a]
:[]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
"!$&'()*+,;="
isUnreserved :: Char -> Bool
isUnreserved :: Char -> Bool
isUnreserved Char
c = Char -> Bool
isAlphaNumChar Char
c Bool -> Bool -> Bool
|| (Char
c forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` String
"-_.~")
unreservedChar :: URIParser String
unreservedChar :: URIParser String
unreservedChar = (forall a. a -> [a] -> [a]
:[]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
isUnreserved
uri :: URIParser URI
uri :: URIParser URI
uri =
do { String
us <- forall tok st a. GenParser tok st a -> GenParser tok st a
try URIParser String
uscheme
; (Maybe URIAuth
ua,String
up) <- URIParser (Maybe URIAuth, String)
hierPart
; String
uq <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option String
"" ( do { Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'?' ; URIParser String
uquery } )
; String
uf <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option String
"" ( do { Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'#' ; URIParser String
ufragment } )
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ URI
{ uriScheme :: String
uriScheme = String
us
, uriAuthority :: Maybe URIAuth
uriAuthority = Maybe URIAuth
ua
, uriPath :: String
uriPath = String
up
, uriQuery :: String
uriQuery = String
uq
, uriFragment :: String
uriFragment = String
uf
}
}
hierPart :: URIParser (Maybe URIAuth, String)
hierPart :: URIParser (Maybe URIAuth, String)
hierPart =
do { String
_ <- forall tok st a. GenParser tok st a -> GenParser tok st a
try (forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"//")
; Maybe URIAuth
ua <- URIParser (Maybe URIAuth)
uauthority
; String
up <- URIParser String
pathAbEmpty
; forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe URIAuth
ua,String
up)
}
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> do { String
up <- URIParser String
pathAbs
; forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. Maybe a
Nothing,String
up)
}
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> do { String
up <- URIParser String
pathRootLess
; forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. Maybe a
Nothing,String
up)
}
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> do { forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. Maybe a
Nothing,String
"")
}
uscheme :: URIParser String
uscheme :: URIParser String
uscheme =
do { String
s <- forall t s a.
GenParser t s a -> GenParser t s a -> GenParser t s [a]
oneThenMany ParsecT String () Identity Char
alphaChar (forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
isSchemeChar)
; Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':'
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
sforall a. [a] -> [a] -> [a]
++String
":"
}
uauthority :: URIParser (Maybe URIAuth)
uauthority :: URIParser (Maybe URIAuth)
uauthority =
do { String
uu <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option String
"" (forall tok st a. GenParser tok st a -> GenParser tok st a
try URIParser String
userinfo)
; String
uh <- URIParser String
host
; String
up <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option String
"" URIParser String
port
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ URIAuth
{ uriUserInfo :: String
uriUserInfo = String
uu
, uriRegName :: String
uriRegName = String
uh
, uriPort :: String
uriPort = String
up
}
}
userinfo :: URIParser String
userinfo :: URIParser String
userinfo =
do { [String]
uu <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (String -> URIParser String
uchar String
";:&=+$,")
; Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'@'
; forall (m :: * -> *) a. Monad m => a -> m a
return (forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
uu forall a. [a] -> [a] -> [a]
++String
"@")
}
host :: URIParser String
host :: URIParser String
host = URIParser String
ipLiteral forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall tok st a. GenParser tok st a -> GenParser tok st a
try URIParser String
ipv4address forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> URIParser String
regName
ipLiteral :: URIParser String
ipLiteral :: URIParser String
ipLiteral =
do { Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'['
; String
ua <- URIParser String
ipv6addrz forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> URIParser String
ipvFuture
; Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
']'
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
"[" forall a. [a] -> [a] -> [a]
++ String
ua forall a. [a] -> [a] -> [a]
++ String
"]"
}
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"IP address literal"
ipvFuture :: URIParser String
ipvFuture :: URIParser String
ipvFuture =
do { Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'v'
; Char
h <- ParsecT String () Identity Char
hexDigitChar
; Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
; String
a <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
isIpvFutureChar)
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Char
'v'forall a. a -> [a] -> [a]
:Char
hforall a. a -> [a] -> [a]
:Char
'.'forall a. a -> [a] -> [a]
:String
a
}
isIpvFutureChar :: Char -> Bool
isIpvFutureChar :: Char -> Bool
isIpvFutureChar Char
c = Char -> Bool
isUnreserved Char
c Bool -> Bool -> Bool
|| Char -> Bool
isSubDelims Char
c Bool -> Bool -> Bool
|| (Char
cforall a. Eq a => a -> a -> Bool
==Char
';')
zoneid :: URIParser String
zoneid :: URIParser String
zoneid = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (URIParser String
unreservedChar forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> URIParser String
escaped)
ipv6addrz :: URIParser String
ipv6addrz :: URIParser String
ipv6addrz = forall a. [a] -> [a] -> [a]
(++) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> URIParser String
ipv6address forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option String
"" (forall tok st a. GenParser tok st a -> GenParser tok st a
try forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [a] -> [a]
(++) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"%25" forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> URIParser String
zoneid)
ipv6address :: URIParser String
ipv6address :: URIParser String
ipv6address =
forall tok st a. GenParser tok st a -> GenParser tok st a
try ( do
{ [String]
a2 <- forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
6 URIParser String
h4c
; String
a3 <- URIParser String
ls32
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
a2 forall a. [a] -> [a] -> [a]
++ String
a3
} )
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall tok st a. GenParser tok st a -> GenParser tok st a
try ( do
{ String
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"::"
; [String]
a2 <- forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
5 URIParser String
h4c
; String
a3 <- URIParser String
ls32
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
"::" forall a. [a] -> [a] -> [a]
++ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
a2 forall a. [a] -> [a] -> [a]
++ String
a3
} )
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall tok st a. GenParser tok st a -> GenParser tok st a
try ( do
{ String
a1 <- Int -> URIParser String
opt_n_h4c_h4 Int
0
; String
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"::"
; [String]
a2 <- forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
4 URIParser String
h4c
; String
a3 <- URIParser String
ls32
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
a1 forall a. [a] -> [a] -> [a]
++ String
"::" forall a. [a] -> [a] -> [a]
++ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
a2 forall a. [a] -> [a] -> [a]
++ String
a3
} )
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall tok st a. GenParser tok st a -> GenParser tok st a
try ( do
{ String
a1 <- Int -> URIParser String
opt_n_h4c_h4 Int
1
; String
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"::"
; [String]
a2 <- forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
3 URIParser String
h4c
; String
a3 <- URIParser String
ls32
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
a1 forall a. [a] -> [a] -> [a]
++ String
"::" forall a. [a] -> [a] -> [a]
++ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
a2 forall a. [a] -> [a] -> [a]
++ String
a3
} )
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall tok st a. GenParser tok st a -> GenParser tok st a
try ( do
{ String
a1 <- Int -> URIParser String
opt_n_h4c_h4 Int
2
; String
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"::"
; [String]
a2 <- forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
2 URIParser String
h4c
; String
a3 <- URIParser String
ls32
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
a1 forall a. [a] -> [a] -> [a]
++ String
"::" forall a. [a] -> [a] -> [a]
++ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
a2 forall a. [a] -> [a] -> [a]
++ String
a3
} )
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall tok st a. GenParser tok st a -> GenParser tok st a
try ( do
{ String
a1 <- Int -> URIParser String
opt_n_h4c_h4 Int
3
; String
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"::"
; String
a2 <- URIParser String
h4c
; String
a3 <- URIParser String
ls32
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
a1 forall a. [a] -> [a] -> [a]
++ String
"::" forall a. [a] -> [a] -> [a]
++ String
a2 forall a. [a] -> [a] -> [a]
++ String
a3
} )
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall tok st a. GenParser tok st a -> GenParser tok st a
try ( do
{ String
a1 <- Int -> URIParser String
opt_n_h4c_h4 Int
4
; String
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"::"
; String
a3 <- URIParser String
ls32
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
a1 forall a. [a] -> [a] -> [a]
++ String
"::" forall a. [a] -> [a] -> [a]
++ String
a3
} )
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall tok st a. GenParser tok st a -> GenParser tok st a
try ( do
{ String
a1 <- Int -> URIParser String
opt_n_h4c_h4 Int
5
; String
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"::"
; String
a3 <- URIParser String
h4
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
a1 forall a. [a] -> [a] -> [a]
++ String
"::" forall a. [a] -> [a] -> [a]
++ String
a3
} )
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall tok st a. GenParser tok st a -> GenParser tok st a
try ( do
{ String
a1 <- Int -> URIParser String
opt_n_h4c_h4 Int
6
; String
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"::"
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
a1 forall a. [a] -> [a] -> [a]
++ String
"::"
} )
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"IPv6 address"
opt_n_h4c_h4 :: Int -> URIParser String
opt_n_h4c_h4 :: Int -> URIParser String
opt_n_h4c_h4 Int
n = forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option String
"" forall a b. (a -> b) -> a -> b
$
do { [String]
a1 <- forall t s a. Int -> Int -> GenParser t s a -> GenParser t s [a]
countMinMax Int
0 Int
n URIParser String
h4c
; String
a2 <- URIParser String
h4
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
a1 forall a. [a] -> [a] -> [a]
++ String
a2
}
ls32 :: URIParser String
ls32 :: URIParser String
ls32 = forall tok st a. GenParser tok st a -> GenParser tok st a
try ( do
{ String
a1 <- URIParser String
h4c
; String
a2 <- URIParser String
h4
; forall (m :: * -> *) a. Monad m => a -> m a
return (String
a1forall a. [a] -> [a] -> [a]
++String
a2)
} )
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> URIParser String
ipv4address
h4c :: URIParser String
h4c :: URIParser String
h4c = forall tok st a. GenParser tok st a -> GenParser tok st a
try forall a b. (a -> b) -> a -> b
$
do { String
a1 <- URIParser String
h4
; Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':'
; ()
_ <- forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':')
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
a1 forall a. [a] -> [a] -> [a]
++ String
":"
}
h4 :: URIParser String
h4 :: URIParser String
h4 = forall t s a. Int -> Int -> GenParser t s a -> GenParser t s [a]
countMinMax Int
1 Int
4 ParsecT String () Identity Char
hexDigitChar
ipv4address :: URIParser String
ipv4address :: URIParser String
ipv4address =
do { String
a1 <- URIParser String
decOctet ; Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
; String
a2 <- URIParser String
decOctet ; Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
; String
a3 <- URIParser String
decOctet ; Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
; String
a4 <- URIParser String
decOctet
; ()
_ <- forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy URIParser String
nameChar
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ String
a1forall a. [a] -> [a] -> [a]
++String
"."forall a. [a] -> [a] -> [a]
++String
a2forall a. [a] -> [a] -> [a]
++String
"."forall a. [a] -> [a] -> [a]
++String
a3forall a. [a] -> [a] -> [a]
++String
"."forall a. [a] -> [a] -> [a]
++String
a4
}
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"IPv4 Address"
decOctet :: URIParser String
decOctet :: URIParser String
decOctet =
do { String
a1 <- forall t s a. Int -> Int -> GenParser t s a -> GenParser t s [a]
countMinMax Int
1 Int
3 ParsecT String () Identity Char
digitChar
; if (forall a. Read a => String -> a
read String
a1 :: Integer) forall a. Ord a => a -> a -> Bool
> Integer
255 then
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Decimal octet value too large"
else
forall (m :: * -> *) a. Monad m => a -> m a
return String
a1
}
regName :: URIParser String
regName :: URIParser String
regName =
do { [String]
ss <- forall t s a. Int -> Int -> GenParser t s a -> GenParser t s [a]
countMinMax Int
0 Int
255 URIParser String
nameChar
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
ss
}
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"Registered name"
nameChar :: URIParser String
nameChar :: URIParser String
nameChar = (URIParser String
unreservedChar forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> URIParser String
escaped forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> URIParser String
subDelims)
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"Name character"
port :: URIParser String
port :: URIParser String
port =
do { Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':'
; String
p <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT String () Identity Char
digitChar
; forall (m :: * -> *) a. Monad m => a -> m a
return (Char
':'forall a. a -> [a] -> [a]
:String
p)
}
pathAbEmpty :: URIParser String
pathAbEmpty :: URIParser String
pathAbEmpty =
do { [String]
ss <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many URIParser String
slashSegment
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
ss
}
pathAbs :: URIParser String
pathAbs :: URIParser String
pathAbs =
do { Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'/'
; String
ss <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option String
"" URIParser String
pathRootLess
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Char
'/'forall a. a -> [a] -> [a]
:String
ss
}
pathNoScheme :: URIParser String
pathNoScheme :: URIParser String
pathNoScheme =
do { String
s1 <- URIParser String
segmentNzc
; [String]
ss <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many URIParser String
slashSegment
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (String
s1forall a. a -> [a] -> [a]
:[String]
ss)
}
pathRootLess :: URIParser String
pathRootLess :: URIParser String
pathRootLess =
do { String
s1 <- URIParser String
segmentNz
; [String]
ss <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many URIParser String
slashSegment
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (String
s1forall a. a -> [a] -> [a]
:[String]
ss)
}
slashSegment :: URIParser String
slashSegment :: URIParser String
slashSegment =
do { Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'/'
; String
s <- URIParser String
segment
; forall (m :: * -> *) a. Monad m => a -> m a
return (Char
'/'forall a. a -> [a] -> [a]
:String
s)
}
segment :: URIParser String
segment :: URIParser String
segment =
do { [String]
ps <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many URIParser String
pchar
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
ps
}
segmentNz :: URIParser String
segmentNz :: URIParser String
segmentNz =
do { [String]
ps <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 URIParser String
pchar
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
ps
}
segmentNzc :: URIParser String
segmentNzc :: URIParser String
segmentNzc =
do { [String]
ps <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (String -> URIParser String
uchar String
"@")
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
ps
}
pchar :: URIParser String
pchar :: URIParser String
pchar = String -> URIParser String
uchar String
":@"
uchar :: String -> URIParser String
uchar :: String -> URIParser String
uchar String
extras =
URIParser String
unreservedChar
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> URIParser String
escaped
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> URIParser String
subDelims
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> do { Char
c <- forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
extras ; forall (m :: * -> *) a. Monad m => a -> m a
return [Char
c] }
uquery :: URIParser String
uquery :: URIParser String
uquery =
do { [String]
ss <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many forall a b. (a -> b) -> a -> b
$ String -> URIParser String
uchar (String
":@"forall a. [a] -> [a] -> [a]
++String
"/?")
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Char
'?'forall a. a -> [a] -> [a]
:forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
ss
}
ufragment :: URIParser String
ufragment :: URIParser String
ufragment =
do { [String]
ss <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many forall a b. (a -> b) -> a -> b
$ String -> URIParser String
uchar (String
":@"forall a. [a] -> [a] -> [a]
++String
"/?")
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Char
'#'forall a. a -> [a] -> [a]
:forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
ss
}
uriReference :: URIParser URI
uriReference :: URIParser URI
uriReference = URIParser URI
uri forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> URIParser URI
relativeRef
relativeRef :: URIParser URI
relativeRef :: URIParser URI
relativeRef =
do { forall a tok st.
Show a =>
GenParser tok st a -> GenParser tok st ()
notMatching URIParser String
uscheme
; (Maybe URIAuth
ua,String
up) <- URIParser (Maybe URIAuth, String)
relativePart
; String
uq <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option String
"" ( do { Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'?' ; URIParser String
uquery } )
; String
uf <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option String
"" ( do { Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'#' ; URIParser String
ufragment } )
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ URI
{ uriScheme :: String
uriScheme = String
""
, uriAuthority :: Maybe URIAuth
uriAuthority = Maybe URIAuth
ua
, uriPath :: String
uriPath = String
up
, uriQuery :: String
uriQuery = String
uq
, uriFragment :: String
uriFragment = String
uf
}
}
relativePart :: URIParser (Maybe URIAuth, String)
relativePart :: URIParser (Maybe URIAuth, String)
relativePart =
do { String
_ <- forall tok st a. GenParser tok st a -> GenParser tok st a
try (forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"//")
; Maybe URIAuth
ua <- URIParser (Maybe URIAuth)
uauthority
; String
up <- URIParser String
pathAbEmpty
; forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe URIAuth
ua,String
up)
}
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> do { String
up <- URIParser String
pathAbs
; forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. Maybe a
Nothing,String
up)
}
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> do { String
up <- URIParser String
pathNoScheme
; forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. Maybe a
Nothing,String
up)
}
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> do { forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. Maybe a
Nothing,String
"")
}
absoluteURI :: URIParser URI
absoluteURI :: URIParser URI
absoluteURI =
do { String
us <- URIParser String
uscheme
; (Maybe URIAuth
ua,String
up) <- URIParser (Maybe URIAuth, String)
hierPart
; String
uq <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option String
"" ( do { Char
_ <- forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'?' ; URIParser String
uquery } )
; forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ URI
{ uriScheme :: String
uriScheme = String
us
, uriAuthority :: Maybe URIAuth
uriAuthority = Maybe URIAuth
ua
, uriPath :: String
uriPath = String
up
, uriQuery :: String
uriQuery = String
uq
, uriFragment :: String
uriFragment = String
""
}
}
isAlphaChar :: Char -> Bool
isAlphaChar :: Char -> Bool
isAlphaChar Char
c = (Char
c forall a. Ord a => a -> a -> Bool
>= Char
'A' Bool -> Bool -> Bool
&& Char
c forall a. Ord a => a -> a -> Bool
<= Char
'Z') Bool -> Bool -> Bool
|| (Char
c forall a. Ord a => a -> a -> Bool
>= Char
'a' Bool -> Bool -> Bool
&& Char
c forall a. Ord a => a -> a -> Bool
<= Char
'z')
isDigitChar :: Char -> Bool
isDigitChar :: Char -> Bool
isDigitChar Char
c = Char
c forall a. Ord a => a -> a -> Bool
>= Char
'0' Bool -> Bool -> Bool
&& Char
c forall a. Ord a => a -> a -> Bool
<= Char
'9'
isAlphaNumChar :: Char -> Bool
isAlphaNumChar :: Char -> Bool
isAlphaNumChar Char
c = Char -> Bool
isAlphaChar Char
c Bool -> Bool -> Bool
|| Char -> Bool
isDigitChar Char
c
isHexDigitChar :: Char -> Bool
isHexDigitChar :: Char -> Bool
isHexDigitChar Char
c = Char -> Bool
isHexDigit Char
c
isSchemeChar :: Char -> Bool
isSchemeChar :: Char -> Bool
isSchemeChar Char
c = Char -> Bool
isAlphaNumChar Char
c Bool -> Bool -> Bool
|| (Char
c forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` String
"+-.")
alphaChar :: URIParser Char
alphaChar :: ParsecT String () Identity Char
alphaChar = forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
isAlphaChar
digitChar :: URIParser Char
digitChar :: ParsecT String () Identity Char
digitChar = forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
isDigitChar
hexDigitChar :: URIParser Char
hexDigitChar :: ParsecT String () Identity Char
hexDigitChar = forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
isHexDigitChar
oneThenMany :: GenParser t s a -> GenParser t s a -> GenParser t s [a]
oneThenMany :: forall t s a.
GenParser t s a -> GenParser t s a -> GenParser t s [a]
oneThenMany GenParser t s a
p1 GenParser t s a
pr =
do { a
a1 <- GenParser t s a
p1
; [a]
ar <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many GenParser t s a
pr
; forall (m :: * -> *) a. Monad m => a -> m a
return (a
a1forall a. a -> [a] -> [a]
:[a]
ar)
}
countMinMax :: Int -> Int -> GenParser t s a -> GenParser t s [a]
countMinMax :: forall t s a. Int -> Int -> GenParser t s a -> GenParser t s [a]
countMinMax Int
m Int
n GenParser t s a
p | Int
m forall a. Ord a => a -> a -> Bool
> Int
0 =
do { a
a1 <- GenParser t s a
p
; [a]
ar <- forall t s a. Int -> Int -> GenParser t s a -> GenParser t s [a]
countMinMax (Int
mforall a. Num a => a -> a -> a
-Int
1) (Int
nforall a. Num a => a -> a -> a
-Int
1) GenParser t s a
p
; forall (m :: * -> *) a. Monad m => a -> m a
return (a
a1forall a. a -> [a] -> [a]
:[a]
ar)
}
countMinMax Int
_ Int
n GenParser t s a
_ | Int
n forall a. Ord a => a -> a -> Bool
<= Int
0 = forall (m :: * -> *) a. Monad m => a -> m a
return []
countMinMax Int
_ Int
n GenParser t s a
p = forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] forall a b. (a -> b) -> a -> b
$
do { a
a1 <- GenParser t s a
p
; [a]
ar <- forall t s a. Int -> Int -> GenParser t s a -> GenParser t s [a]
countMinMax Int
0 (Int
nforall a. Num a => a -> a -> a
-Int
1) GenParser t s a
p
; forall (m :: * -> *) a. Monad m => a -> m a
return (a
a1forall a. a -> [a] -> [a]
:[a]
ar)
}
notMatching :: Show a => GenParser tok st a -> GenParser tok st ()
notMatching :: forall a tok st.
Show a =>
GenParser tok st a -> GenParser tok st ()
notMatching GenParser tok st a
p = do { a
a <- forall tok st a. GenParser tok st a -> GenParser tok st a
try GenParser tok st a
p ; forall s (m :: * -> *) t u a.
Stream s m t =>
String -> ParsecT s u m a
unexpected (forall a. Show a => a -> String
show a
a) } forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (m :: * -> *) a. Monad m => a -> m a
return ()
uriToString :: (String->String) -> URI -> ShowS
uriToString :: (String -> String) -> URI -> String -> String
uriToString String -> String
userinfomap URI { uriScheme :: URI -> String
uriScheme=String
myscheme
, uriAuthority :: URI -> Maybe URIAuth
uriAuthority=Maybe URIAuth
myauthority
, uriPath :: URI -> String
uriPath=String
mypath
, uriQuery :: URI -> String
uriQuery=String
myquery
, uriFragment :: URI -> String
uriFragment=String
myfragment
} =
(String
myschemeforall a. [a] -> [a] -> [a]
++) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> String) -> Maybe URIAuth -> String -> String
uriAuthToString String -> String
userinfomap Maybe URIAuth
myauthority
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
mypathforall a. [a] -> [a] -> [a]
++) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
myqueryforall a. [a] -> [a] -> [a]
++) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
myfragmentforall a. [a] -> [a] -> [a]
++)
uriAuthToString :: (String->String) -> Maybe URIAuth -> ShowS
uriAuthToString :: (String -> String) -> Maybe URIAuth -> String -> String
uriAuthToString String -> String
_ Maybe URIAuth
Nothing = forall a. a -> a
id
uriAuthToString String -> String
userinfomap
(Just URIAuth { uriUserInfo :: URIAuth -> String
uriUserInfo = String
myuinfo
, uriRegName :: URIAuth -> String
uriRegName = String
myregname
, uriPort :: URIAuth -> String
uriPort = String
myport
} ) =
(String
"//"forall a. [a] -> [a] -> [a]
++) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (if forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
myuinfo then forall a. a -> a
id else (String -> String
userinfomap String
myuinfo forall a. [a] -> [a] -> [a]
++))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
myregnameforall a. [a] -> [a] -> [a]
++)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
myportforall a. [a] -> [a] -> [a]
++)
isAllowedInURI :: Char -> Bool
isAllowedInURI :: Char -> Bool
isAllowedInURI Char
c = Char -> Bool
isReserved Char
c Bool -> Bool -> Bool
|| Char -> Bool
isUnreserved Char
c Bool -> Bool -> Bool
|| Char
c forall a. Eq a => a -> a -> Bool
== Char
'%'
isUnescapedInURI :: Char -> Bool
isUnescapedInURI :: Char -> Bool
isUnescapedInURI Char
c = Char -> Bool
isReserved Char
c Bool -> Bool -> Bool
|| Char -> Bool
isUnreserved Char
c
isUnescapedInURIComponent :: Char -> Bool
isUnescapedInURIComponent :: Char -> Bool
isUnescapedInURIComponent Char
c = Bool -> Bool
not (Char -> Bool
isReserved Char
c Bool -> Bool -> Bool
|| Bool -> Bool
not (Char -> Bool
isUnescapedInURI Char
c))
escapeURIChar :: (Char->Bool) -> Char -> String
escapeURIChar :: (Char -> Bool) -> Char -> String
escapeURIChar Char -> Bool
p Char
c
| Char -> Bool
p Char
c = [Char
c]
| Bool
otherwise = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\Int
i -> Char
'%' forall a. a -> [a] -> [a]
: Int -> String -> String
myShowHex Int
i String
"") (Char -> [Int]
utf8EncodeChar Char
c)
where
myShowHex :: Int -> ShowS
myShowHex :: Int -> String -> String
myShowHex Int
n String
r = case forall a.
(Integral a, Show a) =>
a -> (Int -> Char) -> a -> String -> String
showIntAtBase Int
16 forall {a}. Integral a => a -> Char
toChrHex Int
n String
r of
[] -> String
"00"
[Char
x] -> [Char
'0',Char
x]
String
cs -> String
cs
toChrHex :: a -> Char
toChrHex a
d
| a
d forall a. Ord a => a -> a -> Bool
< a
10 = Int -> Char
chr (Char -> Int
ord Char
'0' forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral a
d)
| Bool
otherwise = Int -> Char
chr (Char -> Int
ord Char
'A' forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral (a
d forall a. Num a => a -> a -> a
- a
10))
utf8EncodeChar :: Char -> [Int]
utf8EncodeChar :: Char -> [Int]
utf8EncodeChar = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (Integral a, Num b) => a -> b
fromIntegral forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {a}. (Ord a, Num a, Bits a) => a -> [a]
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord
where
go :: a -> [a]
go a
oc
| a
oc forall a. Ord a => a -> a -> Bool
<= a
0x7f = [a
oc]
| a
oc forall a. Ord a => a -> a -> Bool
<= a
0x7ff = [ a
0xc0 forall a. Num a => a -> a -> a
+ (a
oc forall a. Bits a => a -> Int -> a
`shiftR` Int
6)
, a
0x80 forall a. Num a => a -> a -> a
+ a
oc forall a. Bits a => a -> a -> a
.&. a
0x3f
]
| a
oc forall a. Ord a => a -> a -> Bool
<= a
0xffff = [ a
0xe0 forall a. Num a => a -> a -> a
+ (a
oc forall a. Bits a => a -> Int -> a
`shiftR` Int
12)
, a
0x80 forall a. Num a => a -> a -> a
+ ((a
oc forall a. Bits a => a -> Int -> a
`shiftR` Int
6) forall a. Bits a => a -> a -> a
.&. a
0x3f)
, a
0x80 forall a. Num a => a -> a -> a
+ a
oc forall a. Bits a => a -> a -> a
.&. a
0x3f
]
| Bool
otherwise = [ a
0xf0 forall a. Num a => a -> a -> a
+ (a
oc forall a. Bits a => a -> Int -> a
`shiftR` Int
18)
, a
0x80 forall a. Num a => a -> a -> a
+ ((a
oc forall a. Bits a => a -> Int -> a
`shiftR` Int
12) forall a. Bits a => a -> a -> a
.&. a
0x3f)
, a
0x80 forall a. Num a => a -> a -> a
+ ((a
oc forall a. Bits a => a -> Int -> a
`shiftR` Int
6) forall a. Bits a => a -> a -> a
.&. a
0x3f)
, a
0x80 forall a. Num a => a -> a -> a
+ a
oc forall a. Bits a => a -> a -> a
.&. a
0x3f
]
escapeURIString
:: (Char->Bool)
-> String
-> String
escapeURIString :: (Char -> Bool) -> String -> String
escapeURIString Char -> Bool
p String
s = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ((Char -> Bool) -> Char -> String
escapeURIChar Char -> Bool
p) String
s
unEscapeString :: String -> String
unEscapeString :: String -> String
unEscapeString [] = String
""
unEscapeString s :: String
s@(Char
c:String
cs) = case String -> Maybe (Int, String)
unEscapeByte String
s of
Just (Int
byte, String
rest) -> Int -> String -> String
unEscapeUtf8 Int
byte String
rest
Maybe (Int, String)
Nothing -> Char
c forall a. a -> [a] -> [a]
: String -> String
unEscapeString String
cs
unEscapeByte :: String -> Maybe (Int, String)
unEscapeByte :: String -> Maybe (Int, String)
unEscapeByte (Char
'%':Char
x1:Char
x2:String
s) | Char -> Bool
isHexDigit Char
x1 Bool -> Bool -> Bool
&& Char -> Bool
isHexDigit Char
x2 =
forall a. a -> Maybe a
Just (Char -> Int
digitToInt Char
x1 forall a. Num a => a -> a -> a
* Int
16 forall a. Num a => a -> a -> a
+ Char -> Int
digitToInt Char
x2, String
s)
unEscapeByte String
_ = forall a. Maybe a
Nothing
unEscapeUtf8 :: Int -> String -> String
unEscapeUtf8 :: Int -> String -> String
unEscapeUtf8 Int
c String
rest
| Int
c forall a. Ord a => a -> a -> Bool
< Int
0x80 = Int -> Char
chr Int
c forall a. a -> [a] -> [a]
: String -> String
unEscapeString String
rest
| Int
c forall a. Ord a => a -> a -> Bool
< Int
0xc0 = Char
replacement_character forall a. a -> [a] -> [a]
: String -> String
unEscapeString String
rest
| Int
c forall a. Ord a => a -> a -> Bool
< Int
0xe0 = String
multi1
| Int
c forall a. Ord a => a -> a -> Bool
< Int
0xf0 = Int -> Int -> Int -> String
multi_byte Int
2 Int
0xf Int
0x800
| Int
c forall a. Ord a => a -> a -> Bool
< Int
0xf8 = Int -> Int -> Int -> String
multi_byte Int
3 Int
0x7 Int
0x10000
| Int
c forall a. Ord a => a -> a -> Bool
< Int
0xfc = Int -> Int -> Int -> String
multi_byte Int
4 Int
0x3 Int
0x200000
| Int
c forall a. Ord a => a -> a -> Bool
< Int
0xfe = Int -> Int -> Int -> String
multi_byte Int
5 Int
0x1 Int
0x4000000
| Bool
otherwise = Char
replacement_character forall a. a -> [a] -> [a]
: String -> String
unEscapeString String
rest
where
replacement_character :: Char
replacement_character = Char
'\xfffd'
multi1 :: String
multi1 = case String -> Maybe (Int, String)
unEscapeByte String
rest of
Just (Int
c1, String
ds) | Int
c1 forall a. Bits a => a -> a -> a
.&. Int
0xc0 forall a. Eq a => a -> a -> Bool
== Int
0x80 ->
let d :: Int
d = ((forall a. Enum a => a -> Int
fromEnum Int
c forall a. Bits a => a -> a -> a
.&. Int
0x1f) forall a. Bits a => a -> Int -> a
`shiftL` Int
6) forall a. Bits a => a -> a -> a
.|. forall a. Enum a => a -> Int
fromEnum (Int
c1 forall a. Bits a => a -> a -> a
.&. Int
0x3f)
in if Int
d forall a. Ord a => a -> a -> Bool
>= Int
0x000080 then forall a. Enum a => Int -> a
toEnum Int
d forall a. a -> [a] -> [a]
: String -> String
unEscapeString String
ds
else Char
replacement_character forall a. a -> [a] -> [a]
: String -> String
unEscapeString String
ds
Maybe (Int, String)
_ -> Char
replacement_character forall a. a -> [a] -> [a]
: String -> String
unEscapeString String
rest
multi_byte :: Int -> Int -> Int -> String
multi_byte :: Int -> Int -> Int -> String
multi_byte Int
i Int
mask Int
overlong =
forall {t}.
(Eq t, Num t) =>
t -> String -> Maybe (Int, String) -> Int -> String
aux Int
i String
rest (String -> Maybe (Int, String)
unEscapeByte String
rest) (Int
c forall a. Bits a => a -> a -> a
.&. Int
mask)
where
aux :: t -> String -> Maybe (Int, String) -> Int -> String
aux t
0 String
rs Maybe (Int, String)
_ Int
acc
| Int
overlong forall a. Ord a => a -> a -> Bool
<= Int
acc Bool -> Bool -> Bool
&& Int
acc forall a. Ord a => a -> a -> Bool
<= Int
0x10ffff Bool -> Bool -> Bool
&&
(Int
acc forall a. Ord a => a -> a -> Bool
< Int
0xd800 Bool -> Bool -> Bool
|| Int
0xdfff forall a. Ord a => a -> a -> Bool
< Int
acc) Bool -> Bool -> Bool
&&
(Int
acc forall a. Ord a => a -> a -> Bool
< Int
0xfffe Bool -> Bool -> Bool
|| Int
0xffff forall a. Ord a => a -> a -> Bool
< Int
acc) = Int -> Char
chr Int
acc forall a. a -> [a] -> [a]
: String -> String
unEscapeString String
rs
| Bool
otherwise = Char
replacement_character forall a. a -> [a] -> [a]
: String -> String
unEscapeString String
rs
aux t
n String
_ (Just (Int
r, String
rs)) Int
acc
| Int
r forall a. Bits a => a -> a -> a
.&. Int
0xc0 forall a. Eq a => a -> a -> Bool
== Int
0x80 = t -> String -> Maybe (Int, String) -> Int -> String
aux (t
nforall a. Num a => a -> a -> a
-t
1) String
rs (String -> Maybe (Int, String)
unEscapeByte String
rs)
forall a b. (a -> b) -> a -> b
$! forall a. Bits a => a -> Int -> a
shiftL Int
acc Int
6 forall a. Bits a => a -> a -> a
.|. (Int
r forall a. Bits a => a -> a -> a
.&. Int
0x3f)
aux t
_ String
rs Maybe (Int, String)
_ Int
_ = Char
replacement_character forall a. a -> [a] -> [a]
: String -> String
unEscapeString String
rs
nonStrictRelativeTo :: URI -> URI -> URI
nonStrictRelativeTo :: URI -> URI -> URI
nonStrictRelativeTo URI
ref URI
base = URI -> URI -> URI
relativeTo URI
ref' URI
base
where
ref' :: URI
ref' = if URI -> String
uriScheme URI
ref forall a. Eq a => a -> a -> Bool
== URI -> String
uriScheme URI
base
then URI
ref { uriScheme :: String
uriScheme=String
"" }
else URI
ref
isDefined :: ( MonadPlus m, Eq (m a) ) => m a -> Bool
isDefined :: forall (m :: * -> *) a. (MonadPlus m, Eq (m a)) => m a -> Bool
isDefined m a
a = m a
a forall a. Eq a => a -> a -> Bool
/= forall (m :: * -> *) a. MonadPlus m => m a
mzero
relativeTo :: URI -> URI -> URI
relativeTo :: URI -> URI -> URI
relativeTo URI
ref URI
base
| forall (m :: * -> *) a. (MonadPlus m, Eq (m a)) => m a -> Bool
isDefined ( URI -> String
uriScheme URI
ref ) =
URI -> URI
just_segments URI
ref
| forall (m :: * -> *) a. (MonadPlus m, Eq (m a)) => m a -> Bool
isDefined ( URI -> Maybe URIAuth
uriAuthority URI
ref ) =
URI -> URI
just_segments URI
ref { uriScheme :: String
uriScheme = URI -> String
uriScheme URI
base }
| forall (m :: * -> *) a. (MonadPlus m, Eq (m a)) => m a -> Bool
isDefined ( URI -> String
uriPath URI
ref ) =
if forall a. [a] -> a
head (URI -> String
uriPath URI
ref) forall a. Eq a => a -> a -> Bool
== Char
'/' then
URI -> URI
just_segments URI
ref
{ uriScheme :: String
uriScheme = URI -> String
uriScheme URI
base
, uriAuthority :: Maybe URIAuth
uriAuthority = URI -> Maybe URIAuth
uriAuthority URI
base
}
else
URI -> URI
just_segments URI
ref
{ uriScheme :: String
uriScheme = URI -> String
uriScheme URI
base
, uriAuthority :: Maybe URIAuth
uriAuthority = URI -> Maybe URIAuth
uriAuthority URI
base
, uriPath :: String
uriPath = URI -> URI -> String
mergePaths URI
base URI
ref
}
| forall (m :: * -> *) a. (MonadPlus m, Eq (m a)) => m a -> Bool
isDefined ( URI -> String
uriQuery URI
ref ) =
URI -> URI
just_segments URI
ref
{ uriScheme :: String
uriScheme = URI -> String
uriScheme URI
base
, uriAuthority :: Maybe URIAuth
uriAuthority = URI -> Maybe URIAuth
uriAuthority URI
base
, uriPath :: String
uriPath = URI -> String
uriPath URI
base
}
| Bool
otherwise =
URI -> URI
just_segments URI
ref
{ uriScheme :: String
uriScheme = URI -> String
uriScheme URI
base
, uriAuthority :: Maybe URIAuth
uriAuthority = URI -> Maybe URIAuth
uriAuthority URI
base
, uriPath :: String
uriPath = URI -> String
uriPath URI
base
, uriQuery :: String
uriQuery = URI -> String
uriQuery URI
base
}
where
just_segments :: URI -> URI
just_segments URI
u =
URI
u { uriPath :: String
uriPath = String -> String
removeDotSegments (URI -> String
uriPath URI
u) }
mergePaths :: URI -> URI -> String
mergePaths URI
b URI
r
| forall (m :: * -> *) a. (MonadPlus m, Eq (m a)) => m a -> Bool
isDefined (URI -> Maybe URIAuth
uriAuthority URI
b) Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
pb = Char
'/'forall a. a -> [a] -> [a]
:String
pr
| Bool
otherwise = String -> String
dropLast String
pb forall a. [a] -> [a] -> [a]
++ String
pr
where
pb :: String
pb = URI -> String
uriPath URI
b
pr :: String
pr = URI -> String
uriPath URI
r
dropLast :: String -> String
dropLast = forall a b. (a, b) -> a
fst forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> (String, String)
splitLast
removeDotSegments :: String -> String
removeDotSegments :: String -> String
removeDotSegments (Char
'/':String
ps) = Char
'/'forall a. a -> [a] -> [a]
:String -> [String] -> String
elimDots String
ps []
removeDotSegments String
ps = String -> [String] -> String
elimDots String
ps []
elimDots :: String -> [String] -> String
elimDots :: String -> [String] -> String
elimDots [] [] = String
""
elimDots [] [String]
rs = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall a. [a] -> [a]
reverse [String]
rs)
elimDots ( Char
'.':Char
'/':String
ps) [String]
rs = String -> [String] -> String
elimDots String
ps [String]
rs
elimDots ( Char
'.':[] ) [String]
rs = String -> [String] -> String
elimDots [] [String]
rs
elimDots ( Char
'.':Char
'.':Char
'/':String
ps) [String]
rs = String -> [String] -> String
elimDots String
ps (forall a. Int -> [a] -> [a]
drop Int
1 [String]
rs)
elimDots ( Char
'.':Char
'.':[] ) [String]
rs = String -> [String] -> String
elimDots [] (forall a. Int -> [a] -> [a]
drop Int
1 [String]
rs)
elimDots String
ps [String]
rs = String -> [String] -> String
elimDots String
ps1 (String
rforall a. a -> [a] -> [a]
:[String]
rs)
where
(String
r,String
ps1) = String -> (String, String)
nextSegment String
ps
nextSegment :: String -> (String,String)
nextSegment :: String -> (String, String)
nextSegment String
ps =
case forall a. (a -> Bool) -> [a] -> ([a], [a])
break (forall a. Eq a => a -> a -> Bool
==Char
'/') String
ps of
(String
r,Char
'/':String
ps1) -> (String
rforall a. [a] -> [a] -> [a]
++String
"/",String
ps1)
(String
r,String
_) -> (String
r,[])
segments :: String -> [String]
segments :: String -> [String]
segments String
str = [String] -> [String]
dropLeadingEmpty forall a b. (a -> b) -> a -> b
$ forall b a. (b -> Maybe (a, b)) -> b -> [a]
unfoldr String -> Maybe (String, String)
nextSegmentMaybe String
str
where
nextSegmentMaybe :: String -> Maybe (String, String)
nextSegmentMaybe String
"" = forall a. Maybe a
Nothing
nextSegmentMaybe String
ps =
case forall a. (a -> Bool) -> [a] -> ([a], [a])
break (forall a. Eq a => a -> a -> Bool
==Char
'/') String
ps of
(String
seg, Char
'/':String
ps1) -> forall a. a -> Maybe a
Just (String
seg, String
ps1)
(String
seg, String
_) -> forall a. a -> Maybe a
Just (String
seg, String
"")
dropLeadingEmpty :: [String] -> [String]
dropLeadingEmpty (String
"":[String]
xs) = [String]
xs
dropLeadingEmpty [String]
xs = [String]
xs
pathSegments :: URI -> [String]
pathSegments :: URI -> [String]
pathSegments = String -> [String]
segments forall b c a. (b -> c) -> (a -> b) -> a -> c
. URI -> String
uriPath
splitLast :: String -> (String,String)
splitLast :: String -> (String, String)
splitLast String
p = (forall a. [a] -> [a]
reverse String
revpath,forall a. [a] -> [a]
reverse String
revname)
where
(String
revname,String
revpath) = forall a. (a -> Bool) -> [a] -> ([a], [a])
break (forall a. Eq a => a -> a -> Bool
==Char
'/') forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [a]
reverse String
p
relativeFrom :: URI -> URI -> URI
relativeFrom :: URI -> URI -> URI
relativeFrom URI
uabs URI
base
| forall b a. Eq b => (a -> b) -> a -> a -> Bool
diff URI -> String
uriScheme URI
uabs URI
base = URI
uabs
| forall b a. Eq b => (a -> b) -> a -> a -> Bool
diff URI -> Maybe URIAuth
uriAuthority URI
uabs URI
base = URI
uabs { uriScheme :: String
uriScheme = String
"" }
| forall b a. Eq b => (a -> b) -> a -> a -> Bool
diff URI -> String
uriPath URI
uabs URI
base = URI
uabs
{ uriScheme :: String
uriScheme = String
""
, uriAuthority :: Maybe URIAuth
uriAuthority = forall a. Maybe a
Nothing
, uriPath :: String
uriPath = String -> String -> String
relPathFrom (String -> String
removeBodyDotSegments forall a b. (a -> b) -> a -> b
$ URI -> String
uriPath URI
uabs)
(String -> String
removeBodyDotSegments forall a b. (a -> b) -> a -> b
$ URI -> String
uriPath URI
base)
}
| forall b a. Eq b => (a -> b) -> a -> a -> Bool
diff URI -> String
uriQuery URI
uabs URI
base = URI
uabs
{ uriScheme :: String
uriScheme = String
""
, uriAuthority :: Maybe URIAuth
uriAuthority = forall a. Maybe a
Nothing
, uriPath :: String
uriPath = String
""
}
| Bool
otherwise = URI
uabs
{ uriScheme :: String
uriScheme = String
""
, uriAuthority :: Maybe URIAuth
uriAuthority = forall a. Maybe a
Nothing
, uriPath :: String
uriPath = String
""
, uriQuery :: String
uriQuery = String
""
}
where
diff :: Eq b => (a -> b) -> a -> a -> Bool
diff :: forall b a. Eq b => (a -> b) -> a -> a -> Bool
diff a -> b
sel a
u1 a
u2 = a -> b
sel a
u1 forall a. Eq a => a -> a -> Bool
/= a -> b
sel a
u2
removeBodyDotSegments :: String -> String
removeBodyDotSegments String
p = String -> String
removeDotSegments String
p1 forall a. [a] -> [a] -> [a]
++ String
p2
where
(String
p1,String
p2) = String -> (String, String)
splitLast String
p
relPathFrom :: String -> String -> String
relPathFrom :: String -> String -> String
relPathFrom [] String
_ = String
"/"
relPathFrom String
pabs [] = String
pabs
relPathFrom String
pabs String
base =
if String
sa1 forall a. Eq a => a -> a -> Bool
== String
sb1
then if String
sa1 forall a. Eq a => a -> a -> Bool
== String
"/"
then if String
sa2 forall a. Eq a => a -> a -> Bool
== String
sb2
then String -> String -> String
relPathFrom1 String
ra2 String
rb2
else
String
pabs
else String -> String -> String
relPathFrom1 String
ra1 String
rb1
else String
pabs
where
(String
sa1,String
ra1) = String -> (String, String)
nextSegment String
pabs
(String
sb1,String
rb1) = String -> (String, String)
nextSegment String
base
(String
sa2,String
ra2) = String -> (String, String)
nextSegment String
ra1
(String
sb2,String
rb2) = String -> (String, String)
nextSegment String
rb1
relPathFrom1 :: String -> String -> String
relPathFrom1 :: String -> String -> String
relPathFrom1 String
pabs String
base = String
relName
where
(String
sa,String
na) = String -> (String, String)
splitLast String
pabs
(String
sb,String
nb) = String -> (String, String)
splitLast String
base
rp :: String
rp = String -> String -> String
relSegsFrom String
sa String
sb
relName :: String
relName = if forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
rp then
if String
na forall a. Eq a => a -> a -> Bool
== String
nb then String
""
else if forall {t :: * -> *}. Foldable t => t Char -> Bool
protect String
na then String
"./"forall a. [a] -> [a] -> [a]
++String
na
else String
na
else
String
rpforall a. [a] -> [a] -> [a]
++String
na
protect :: t Char -> Bool
protect t Char
s = forall (t :: * -> *) a. Foldable t => t a -> Bool
null t Char
s Bool -> Bool -> Bool
|| Char
':' forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` t Char
s
relSegsFrom :: String -> String -> String
relSegsFrom :: String -> String -> String
relSegsFrom [] [] = String
""
relSegsFrom String
sabs String
base =
if String
sa1 forall a. Eq a => a -> a -> Bool
== String
sb1
then String -> String -> String
relSegsFrom String
ra1 String
rb1
else String -> String -> String
difSegsFrom String
sabs String
base
where
(String
sa1,String
ra1) = String -> (String, String)
nextSegment String
sabs
(String
sb1,String
rb1) = String -> (String, String)
nextSegment String
base
difSegsFrom :: String -> String -> String
difSegsFrom :: String -> String -> String
difSegsFrom String
sabs String
"" = String
sabs
difSegsFrom String
sabs String
base = String -> String -> String
difSegsFrom (String
"../"forall a. [a] -> [a] -> [a]
++String
sabs) (forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ String -> (String, String)
nextSegment String
base)
normalizeCase :: String -> String
normalizeCase :: String -> String
normalizeCase String
uristr = String -> String
ncScheme String
uristr
where
ncScheme :: String -> String
ncScheme (Char
':':String
cs) = Char
':'forall a. a -> [a] -> [a]
:String -> String
ncEscape String
cs
ncScheme (Char
c:String
cs) | Char -> Bool
isSchemeChar Char
c = Char -> Char
toLower Char
cforall a. a -> [a] -> [a]
:String -> String
ncScheme String
cs
ncScheme String
_ = String -> String
ncEscape String
uristr
ncEscape :: String -> String
ncEscape (Char
'%':Char
h1:Char
h2:String
cs) = Char
'%'forall a. a -> [a] -> [a]
:Char -> Char
toUpper Char
h1forall a. a -> [a] -> [a]
:Char -> Char
toUpper Char
h2forall a. a -> [a] -> [a]
:String -> String
ncEscape String
cs
ncEscape (Char
c:String
cs) = Char
cforall a. a -> [a] -> [a]
:String -> String
ncEscape String
cs
ncEscape [] = []
normalizeEscape :: String -> String
normalizeEscape :: String -> String
normalizeEscape (Char
'%':Char
h1:Char
h2:String
cs)
| Char -> Bool
isHexDigit Char
h1 Bool -> Bool -> Bool
&& Char -> Bool
isHexDigit Char
h2 Bool -> Bool -> Bool
&& Char -> Bool
isUnreserved Char
escval =
Char
escvalforall a. a -> [a] -> [a]
:String -> String
normalizeEscape String
cs
where
escval :: Char
escval = Int -> Char
chr (Char -> Int
digitToInt Char
h1forall a. Num a => a -> a -> a
*Int
16forall a. Num a => a -> a -> a
+Char -> Int
digitToInt Char
h2)
normalizeEscape (Char
c:String
cs) = Char
cforall a. a -> [a] -> [a]
:String -> String
normalizeEscape String
cs
normalizeEscape [] = []
normalizePathSegments :: String -> String
normalizePathSegments :: String -> String
normalizePathSegments String
uristr = Maybe URI -> String
normstr Maybe URI
juri
where
juri :: Maybe URI
juri = String -> Maybe URI
parseURI String
uristr
normstr :: Maybe URI -> String
normstr Maybe URI
Nothing = String
uristr
normstr (Just URI
u) = forall a. Show a => a -> String
show (URI -> URI
normuri URI
u)
normuri :: URI -> URI
normuri URI
u = URI
u { uriPath :: String
uriPath = String -> String
removeDotSegments (URI -> String
uriPath URI
u) }
#if __GLASGOW_HASKELL__ >= 800
deriving instance Lift URI
deriving instance Lift URIAuth
#else
instance Lift URI where
lift (URI {..}) = [| URI {..} |]
instance Lift URIAuth where
lift (URIAuth {..}) = [| URIAuth {..} |]
#endif
{-# DEPRECATED parseabsoluteURI "use parseAbsoluteURI" #-}
parseabsoluteURI :: String -> Maybe URI
parseabsoluteURI :: String -> Maybe URI
parseabsoluteURI = String -> Maybe URI
parseAbsoluteURI
{-# DEPRECATED escapeString "use escapeURIString, and note the flipped arguments" #-}
escapeString :: String -> (Char->Bool) -> String
escapeString :: String -> (Char -> Bool) -> String
escapeString = forall a b c. (a -> b -> c) -> b -> a -> c
flip (Char -> Bool) -> String -> String
escapeURIString
{-# DEPRECATED reserved "use isReserved" #-}
reserved :: Char -> Bool
reserved :: Char -> Bool
reserved = Char -> Bool
isReserved
{-# DEPRECATED unreserved "use isUnreserved" #-}
unreserved :: Char -> Bool
unreserved :: Char -> Bool
unreserved = Char -> Bool
isUnreserved
{-# DEPRECATED scheme "use uriScheme" #-}
scheme :: URI -> String
scheme :: URI -> String
scheme = forall a. ([a] -> [a]) -> [a] -> [a]
orNull forall a. [a] -> [a]
init forall b c a. (b -> c) -> (a -> b) -> a -> c
. URI -> String
uriScheme
runShowS :: ShowS -> String
runShowS :: (String -> String) -> String
runShowS String -> String
s = String -> String
s String
""
{-# DEPRECATED authority "use uriAuthority, and note changed functionality" #-}
authority :: URI -> String
authority :: URI -> String
authority = String -> String
dropss forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> String) -> String
runShowS forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> String) -> Maybe URIAuth -> String -> String
uriAuthToString forall a. a -> a
id forall b c a. (b -> c) -> (a -> b) -> a -> c
. URI -> Maybe URIAuth
uriAuthority
where
dropss :: String -> String
dropss (Char
'/':Char
'/':String
s) = String
s
dropss String
s = String
s
{-# DEPRECATED path "use uriPath" #-}
path :: URI -> String
path :: URI -> String
path = URI -> String
uriPath
{-# DEPRECATED query "use uriQuery, and note changed functionality" #-}
query :: URI -> String
query :: URI -> String
query = forall a. ([a] -> [a]) -> [a] -> [a]
orNull forall a. [a] -> [a]
tail forall b c a. (b -> c) -> (a -> b) -> a -> c
. URI -> String
uriQuery
{-# DEPRECATED fragment "use uriFragment, and note changed functionality" #-}
fragment :: URI -> String
fragment :: URI -> String
fragment = forall a. ([a] -> [a]) -> [a] -> [a]
orNull forall a. [a] -> [a]
tail forall b c a. (b -> c) -> (a -> b) -> a -> c
. URI -> String
uriFragment
orNull :: ([a]->[a]) -> [a] -> [a]
orNull :: forall a. ([a] -> [a]) -> [a] -> [a]
orNull [a] -> [a]
_ [] = []
orNull [a] -> [a]
f [a]
as = [a] -> [a]
f [a]
as