{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
module URI.ByteString.Lens where
import Control.Applicative
import Data.ByteString (ByteString)
import Data.Word
import Prelude
import URI.ByteString.Types
schemeBSL
:: Lens' Scheme ByteString
schemeBSL :: Lens' Scheme ByteString
schemeBSL =
(Scheme -> ByteString)
-> (Scheme -> ByteString -> Scheme) -> Lens' Scheme ByteString
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Scheme -> ByteString
schemeBS (\Scheme
a ByteString
b -> Scheme
a { schemeBS = b})
{-# INLINE schemeBSL #-}
hostBSL
:: Lens' Host ByteString
hostBSL :: Lens' Host ByteString
hostBSL =
(Host -> ByteString)
-> (Host -> ByteString -> Host) -> Lens' Host ByteString
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Host -> ByteString
hostBS (\Host
a ByteString
b -> Host
a { hostBS = b})
{-# INLINE hostBSL #-}
portNumberL
:: Lens' Port Int
portNumberL :: Lens' Port Int
portNumberL =
(Port -> Int) -> (Port -> Int -> Port) -> Lens' Port Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Port -> Int
portNumber (\Port
a Int
b -> Port
a { portNumber = b})
{-# INLINE portNumberL #-}
authorityUserInfoL
:: Lens' Authority (Maybe UserInfo)
authorityUserInfoL :: Lens' Authority (Maybe UserInfo)
authorityUserInfoL =
(Authority -> Maybe UserInfo)
-> (Authority -> Maybe UserInfo -> Authority)
-> Lens' Authority (Maybe UserInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Authority -> Maybe UserInfo
authorityUserInfo (\Authority
a Maybe UserInfo
b -> Authority
a { authorityUserInfo = b})
{-# INLINE authorityUserInfoL #-}
authorityHostL
:: Lens' Authority Host
authorityHostL :: Lens' Authority Host
authorityHostL =
(Authority -> Host)
-> (Authority -> Host -> Authority) -> Lens' Authority Host
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Authority -> Host
authorityHost (\Authority
a Host
b -> Authority
a { authorityHost = b})
{-# INLINE authorityHostL #-}
authorityPortL
:: Lens' Authority (Maybe Port)
authorityPortL :: Lens' Authority (Maybe Port)
authorityPortL =
(Authority -> Maybe Port)
-> (Authority -> Maybe Port -> Authority)
-> Lens' Authority (Maybe Port)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Authority -> Maybe Port
authorityPort (\Authority
a Maybe Port
b -> Authority
a { authorityPort = b})
{-# INLINE authorityPortL #-}
uiUsernameL
:: Lens' UserInfo ByteString
uiUsernameL :: Lens' UserInfo ByteString
uiUsernameL =
(UserInfo -> ByteString)
-> (UserInfo -> ByteString -> UserInfo)
-> Lens' UserInfo ByteString
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens UserInfo -> ByteString
uiUsername (\UserInfo
a ByteString
b -> UserInfo
a { uiUsername = b})
{-# INLINE uiUsernameL #-}
uiPasswordL
:: Lens' UserInfo ByteString
uiPasswordL :: Lens' UserInfo ByteString
uiPasswordL =
(UserInfo -> ByteString)
-> (UserInfo -> ByteString -> UserInfo)
-> Lens' UserInfo ByteString
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens UserInfo -> ByteString
uiPassword (\UserInfo
a ByteString
b -> UserInfo
a { uiPassword = b})
{-# INLINE uiPasswordL #-}
queryPairsL
:: Lens' Query [(ByteString, ByteString)]
queryPairsL :: Lens' Query [(ByteString, ByteString)]
queryPairsL =
(Query -> [(ByteString, ByteString)])
-> (Query -> [(ByteString, ByteString)] -> Query)
-> Lens' Query [(ByteString, ByteString)]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Query -> [(ByteString, ByteString)]
queryPairs (\Query
a [(ByteString, ByteString)]
b -> Query
a { queryPairs = b})
{-# INLINE queryPairsL #-}
uriAuthorityL :: Lens' URI (Maybe Authority)
uriAuthorityL :: Lens' URI (Maybe Authority)
uriAuthorityL =
(URI -> Maybe Authority)
-> (URI -> Maybe Authority -> URI) -> Lens' URI (Maybe Authority)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URI -> Maybe Authority
uriAuthority (\URI
a Maybe Authority
b -> URI
a { uriAuthority = b})
{-# INLINE uriAuthorityL #-}
{-# DEPRECATED uriAuthorityL "Use 'authorityL' instead" #-}
uriPathL :: Lens' URI ByteString
uriPathL :: Lens' URI ByteString
uriPathL =
(URI -> ByteString)
-> (URI -> ByteString -> URI) -> Lens' URI ByteString
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URI -> ByteString
uriPath (\URI
a ByteString
b -> URI
a { uriPath = b})
{-# INLINE uriPathL #-}
{-# DEPRECATED uriPathL "Use 'pathL' instead" #-}
uriQueryL :: Lens' URI Query
uriQueryL :: Lens' URI Query
uriQueryL =
(URI -> Query) -> (URI -> Query -> URI) -> Lens' URI Query
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URI -> Query
uriQuery (\URI
a Query
b -> URI
a { uriQuery = b})
{-# INLINE uriQueryL #-}
{-# DEPRECATED uriQueryL "Use 'queryL' instead" #-}
uriFragmentL :: Lens' URI (Maybe ByteString)
uriFragmentL :: Lens' URI (Maybe ByteString)
uriFragmentL =
(URI -> Maybe ByteString)
-> (URI -> Maybe ByteString -> URI) -> Lens' URI (Maybe ByteString)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URI -> Maybe ByteString
uriFragment (\URI
a Maybe ByteString
b -> URI
a { uriFragment = b})
{-# INLINE uriFragmentL #-}
{-# DEPRECATED uriFragmentL "Use 'fragmentL' instead" #-}
rrAuthorityL :: Lens' RelativeRef (Maybe Authority)
rrAuthorityL :: Lens' RelativeRef (Maybe Authority)
rrAuthorityL =
(RelativeRef -> Maybe Authority)
-> (RelativeRef -> Maybe Authority -> RelativeRef)
-> Lens' RelativeRef (Maybe Authority)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens RelativeRef -> Maybe Authority
rrAuthority (\RelativeRef
a Maybe Authority
b -> RelativeRef
a { rrAuthority = b})
{-# INLINE rrAuthorityL #-}
{-# DEPRECATED rrAuthorityL "Use 'authorityL' instead" #-}
rrPathL :: Lens' RelativeRef ByteString
rrPathL :: Lens' RelativeRef ByteString
rrPathL =
(RelativeRef -> ByteString)
-> (RelativeRef -> ByteString -> RelativeRef)
-> Lens' RelativeRef ByteString
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens RelativeRef -> ByteString
rrPath (\RelativeRef
a ByteString
b -> RelativeRef
a { rrPath = b})
{-# INLINE rrPathL #-}
{-# DEPRECATED rrPathL "Use 'pathL' instead" #-}
rrQueryL :: Lens' RelativeRef Query
rrQueryL :: Lens' RelativeRef Query
rrQueryL =
(RelativeRef -> Query)
-> (RelativeRef -> Query -> RelativeRef) -> Lens' RelativeRef Query
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens RelativeRef -> Query
rrQuery (\RelativeRef
a Query
b -> RelativeRef
a { rrQuery = b})
{-# INLINE rrQueryL #-}
{-# DEPRECATED rrQueryL "Use 'queryL' instead" #-}
rrFragmentL :: Lens' RelativeRef (Maybe ByteString)
rrFragmentL :: Lens' RelativeRef (Maybe ByteString)
rrFragmentL =
(RelativeRef -> Maybe ByteString)
-> (RelativeRef -> Maybe ByteString -> RelativeRef)
-> Lens' RelativeRef (Maybe ByteString)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens RelativeRef -> Maybe ByteString
rrFragment (\RelativeRef
a Maybe ByteString
b -> RelativeRef
a { rrFragment = b})
{-# INLINE rrFragmentL #-}
{-# DEPRECATED rrFragmentL "Use 'fragmentL' instead" #-}
uriSchemeL :: Lens' (URIRef Absolute) Scheme
uriSchemeL :: Lens' URI Scheme
uriSchemeL = (URI -> Scheme) -> (URI -> Scheme -> URI) -> Lens' URI Scheme
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URI -> Scheme
uriScheme URI -> Scheme -> URI
setter where
setter :: URIRef Absolute -> Scheme -> URIRef Absolute
setter :: URI -> Scheme -> URI
setter (URI Scheme
_ Maybe Authority
b ByteString
c Query
d Maybe ByteString
e) Scheme
a' = Scheme
-> Maybe Authority
-> ByteString
-> Query
-> Maybe ByteString
-> URI
URI Scheme
a' Maybe Authority
b ByteString
c Query
d Maybe ByteString
e
{-# INLINE uriSchemeL #-}
authorityL :: Lens' (URIRef a) (Maybe Authority)
authorityL :: forall a (f :: * -> *).
Functor f =>
(Maybe Authority -> f (Maybe Authority))
-> URIRef a -> f (URIRef a)
authorityL = (URIRef a -> Maybe Authority)
-> (URIRef a -> Maybe Authority -> URIRef a)
-> Lens (URIRef a) (URIRef a) (Maybe Authority) (Maybe Authority)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URIRef a -> Maybe Authority
forall a. URIRef a -> Maybe Authority
getter URIRef a -> Maybe Authority -> URIRef a
forall a. URIRef a -> Maybe Authority -> URIRef a
setter where
getter :: URIRef a -> Maybe Authority
getter :: forall a. URIRef a -> Maybe Authority
getter (URI {Maybe ByteString
Maybe Authority
ByteString
Query
Scheme
uriAuthority :: URI -> Maybe Authority
uriPath :: URI -> ByteString
uriQuery :: URI -> Query
uriFragment :: URI -> Maybe ByteString
uriScheme :: URI -> Scheme
uriScheme :: Scheme
uriAuthority :: Maybe Authority
uriPath :: ByteString
uriQuery :: Query
uriFragment :: Maybe ByteString
..}) = Maybe Authority
uriAuthority
getter (RelativeRef {Maybe ByteString
Maybe Authority
ByteString
Query
rrAuthority :: RelativeRef -> Maybe Authority
rrPath :: RelativeRef -> ByteString
rrQuery :: RelativeRef -> Query
rrFragment :: RelativeRef -> Maybe ByteString
rrAuthority :: Maybe Authority
rrPath :: ByteString
rrQuery :: Query
rrFragment :: Maybe ByteString
..}) = Maybe Authority
rrAuthority
setter :: URIRef a -> Maybe Authority -> URIRef a
setter :: forall a. URIRef a -> Maybe Authority -> URIRef a
setter (URI Scheme
a Maybe Authority
_ ByteString
c Query
d Maybe ByteString
e) Maybe Authority
b' = Scheme
-> Maybe Authority
-> ByteString
-> Query
-> Maybe ByteString
-> URI
URI Scheme
a Maybe Authority
b' ByteString
c Query
d Maybe ByteString
e
setter (RelativeRef Maybe Authority
_ ByteString
c Query
d Maybe ByteString
e) Maybe Authority
b' = Maybe Authority
-> ByteString -> Query -> Maybe ByteString -> RelativeRef
RelativeRef Maybe Authority
b' ByteString
c Query
d Maybe ByteString
e
{-# INLINE authorityL #-}
pathL :: Lens' (URIRef a) ByteString
pathL :: forall a (f :: * -> *).
Functor f =>
(ByteString -> f ByteString) -> URIRef a -> f (URIRef a)
pathL = (URIRef a -> ByteString)
-> (URIRef a -> ByteString -> URIRef a)
-> Lens (URIRef a) (URIRef a) ByteString ByteString
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URIRef a -> ByteString
forall a. URIRef a -> ByteString
getter URIRef a -> ByteString -> URIRef a
forall a. URIRef a -> ByteString -> URIRef a
setter where
getter :: URIRef a -> ByteString
getter :: forall a. URIRef a -> ByteString
getter (URI {Maybe ByteString
Maybe Authority
ByteString
Query
Scheme
uriAuthority :: URI -> Maybe Authority
uriPath :: URI -> ByteString
uriQuery :: URI -> Query
uriFragment :: URI -> Maybe ByteString
uriScheme :: URI -> Scheme
uriScheme :: Scheme
uriAuthority :: Maybe Authority
uriPath :: ByteString
uriQuery :: Query
uriFragment :: Maybe ByteString
..}) = ByteString
uriPath
getter (RelativeRef {Maybe ByteString
Maybe Authority
ByteString
Query
rrAuthority :: RelativeRef -> Maybe Authority
rrPath :: RelativeRef -> ByteString
rrQuery :: RelativeRef -> Query
rrFragment :: RelativeRef -> Maybe ByteString
rrAuthority :: Maybe Authority
rrPath :: ByteString
rrQuery :: Query
rrFragment :: Maybe ByteString
..}) = ByteString
rrPath
setter :: URIRef a -> ByteString -> URIRef a
setter :: forall a. URIRef a -> ByteString -> URIRef a
setter (URI Scheme
a Maybe Authority
b ByteString
_ Query
d Maybe ByteString
e) ByteString
c' = Scheme
-> Maybe Authority
-> ByteString
-> Query
-> Maybe ByteString
-> URI
URI Scheme
a Maybe Authority
b ByteString
c' Query
d Maybe ByteString
e
setter (RelativeRef Maybe Authority
b ByteString
_ Query
d Maybe ByteString
e) ByteString
c' = Maybe Authority
-> ByteString -> Query -> Maybe ByteString -> RelativeRef
RelativeRef Maybe Authority
b ByteString
c' Query
d Maybe ByteString
e
{-# INLINE pathL #-}
queryL :: Lens' (URIRef a) Query
queryL :: forall a (f :: * -> *).
Functor f =>
(Query -> f Query) -> URIRef a -> f (URIRef a)
queryL = (URIRef a -> Query)
-> (URIRef a -> Query -> URIRef a)
-> Lens (URIRef a) (URIRef a) Query Query
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URIRef a -> Query
forall a. URIRef a -> Query
getter URIRef a -> Query -> URIRef a
forall a. URIRef a -> Query -> URIRef a
setter where
getter :: URIRef a -> Query
getter :: forall a. URIRef a -> Query
getter (URI {Maybe ByteString
Maybe Authority
ByteString
Query
Scheme
uriAuthority :: URI -> Maybe Authority
uriPath :: URI -> ByteString
uriQuery :: URI -> Query
uriFragment :: URI -> Maybe ByteString
uriScheme :: URI -> Scheme
uriScheme :: Scheme
uriAuthority :: Maybe Authority
uriPath :: ByteString
uriQuery :: Query
uriFragment :: Maybe ByteString
..}) = Query
uriQuery
getter (RelativeRef {Maybe ByteString
Maybe Authority
ByteString
Query
rrAuthority :: RelativeRef -> Maybe Authority
rrPath :: RelativeRef -> ByteString
rrQuery :: RelativeRef -> Query
rrFragment :: RelativeRef -> Maybe ByteString
rrAuthority :: Maybe Authority
rrPath :: ByteString
rrQuery :: Query
rrFragment :: Maybe ByteString
..}) = Query
rrQuery
setter :: URIRef a -> Query -> URIRef a
setter :: forall a. URIRef a -> Query -> URIRef a
setter (URI Scheme
a Maybe Authority
b ByteString
c Query
_ Maybe ByteString
e) Query
d' = Scheme
-> Maybe Authority
-> ByteString
-> Query
-> Maybe ByteString
-> URI
URI Scheme
a Maybe Authority
b ByteString
c Query
d' Maybe ByteString
e
setter (RelativeRef Maybe Authority
b ByteString
c Query
_ Maybe ByteString
e) Query
d' = Maybe Authority
-> ByteString -> Query -> Maybe ByteString -> RelativeRef
RelativeRef Maybe Authority
b ByteString
c Query
d' Maybe ByteString
e
{-# INLINE queryL #-}
fragmentL :: Lens' (URIRef a) (Maybe ByteString)
fragmentL :: forall a (f :: * -> *).
Functor f =>
(Maybe ByteString -> f (Maybe ByteString))
-> URIRef a -> f (URIRef a)
fragmentL = (URIRef a -> Maybe ByteString)
-> (URIRef a -> Maybe ByteString -> URIRef a)
-> Lens (URIRef a) (URIRef a) (Maybe ByteString) (Maybe ByteString)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URIRef a -> Maybe ByteString
forall a. URIRef a -> Maybe ByteString
getter URIRef a -> Maybe ByteString -> URIRef a
forall a. URIRef a -> Maybe ByteString -> URIRef a
setter where
getter :: URIRef a -> Maybe ByteString
getter :: forall a. URIRef a -> Maybe ByteString
getter (URI {Maybe ByteString
Maybe Authority
ByteString
Query
Scheme
uriAuthority :: URI -> Maybe Authority
uriPath :: URI -> ByteString
uriQuery :: URI -> Query
uriFragment :: URI -> Maybe ByteString
uriScheme :: URI -> Scheme
uriScheme :: Scheme
uriAuthority :: Maybe Authority
uriPath :: ByteString
uriQuery :: Query
uriFragment :: Maybe ByteString
..}) = Maybe ByteString
uriFragment
getter (RelativeRef {Maybe ByteString
Maybe Authority
ByteString
Query
rrAuthority :: RelativeRef -> Maybe Authority
rrPath :: RelativeRef -> ByteString
rrQuery :: RelativeRef -> Query
rrFragment :: RelativeRef -> Maybe ByteString
rrAuthority :: Maybe Authority
rrPath :: ByteString
rrQuery :: Query
rrFragment :: Maybe ByteString
..}) = Maybe ByteString
rrFragment
setter :: URIRef a -> Maybe ByteString -> URIRef a
setter :: forall a. URIRef a -> Maybe ByteString -> URIRef a
setter (URI Scheme
a Maybe Authority
b ByteString
c Query
d Maybe ByteString
_) Maybe ByteString
e' = Scheme
-> Maybe Authority
-> ByteString
-> Query
-> Maybe ByteString
-> URI
URI Scheme
a Maybe Authority
b ByteString
c Query
d Maybe ByteString
e'
setter (RelativeRef Maybe Authority
b ByteString
c Query
d Maybe ByteString
_) Maybe ByteString
e' = Maybe Authority
-> ByteString -> Query -> Maybe ByteString -> RelativeRef
RelativeRef Maybe Authority
b ByteString
c Query
d Maybe ByteString
e'
{-# INLINE fragmentL #-}
upoValidQueryCharL :: Lens' URIParserOptions (Word8 -> Bool)
upoValidQueryCharL :: Lens' URIParserOptions (Word8 -> Bool)
upoValidQueryCharL =
(URIParserOptions -> Word8 -> Bool)
-> (URIParserOptions -> (Word8 -> Bool) -> URIParserOptions)
-> Lens' URIParserOptions (Word8 -> Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URIParserOptions -> Word8 -> Bool
upoValidQueryChar (\URIParserOptions
a Word8 -> Bool
b -> URIParserOptions
a { upoValidQueryChar = b})
{-# INLINE upoValidQueryCharL #-}
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
type Lens' s a = Lens s s a a
lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
lens :: forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens s -> a
sa s -> b -> t
sbt a -> f b
afb s
s = s -> b -> t
sbt s
s (b -> t) -> f b -> f t
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
afb (s -> a
sa s
s)
{-# INLINE lens #-}