{-# LANGUAGE CPP #-}
{-# LANGUAGE Rank2Types #-}
#if __GLASGOW_HASKELL__ > 704
{-# LANGUAGE Safe #-}
#elif __GLASGOW_HASKELL__ > 702
{-# LANGUAGE Trustworthy #-}
#endif
-- | Network uri lenses
module Network.URI.Lens
  ( uriRegNameLens
  , uriUserInfoLens
  , uriPortLens
  , uriAuthorityLens
  , uriSchemeLens
  , uriPathLens
  , uriQueryLens
  , uriFragmentLens
  ) where

#if __GLASGOW_HASKELL__ < 710
import           Control.Applicative
#endif
import           Network.URI

type Lens' s a = Lens s s a a
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t

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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
afb (s -> a
sa s
s)

uriRegNameLens :: Lens' URIAuth String
uriRegNameLens :: Lens' URIAuth String
uriRegNameLens = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URIAuth -> String
uriRegName (\URIAuth
parent String
newVal -> URIAuth
parent {uriRegName :: String
uriRegName = String
newVal})

uriUserInfoLens :: Lens' URIAuth String
uriUserInfoLens :: Lens' URIAuth String
uriUserInfoLens =
  forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URIAuth -> String
uriUserInfo (\URIAuth
parent String
newVal -> URIAuth
parent {uriUserInfo :: String
uriUserInfo = String
newVal})

uriPortLens :: Lens' URIAuth String
uriPortLens :: Lens' URIAuth String
uriPortLens = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URIAuth -> String
uriPort (\URIAuth
parent String
newVal -> URIAuth
parent {uriPort :: String
uriPort = String
newVal})

uriAuthorityLens :: Lens' URI (Maybe URIAuth)
uriAuthorityLens :: Lens' URI (Maybe URIAuth)
uriAuthorityLens =
  forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URI -> Maybe URIAuth
uriAuthority (\URI
parent Maybe URIAuth
newVal -> URI
parent {uriAuthority :: Maybe URIAuth
uriAuthority = Maybe URIAuth
newVal})

uriSchemeLens :: Lens' URI String
uriSchemeLens :: Lens' URI String
uriSchemeLens = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URI -> String
uriScheme (\URI
parent String
newVal -> URI
parent {uriScheme :: String
uriScheme = String
newVal})

uriPathLens :: Lens' URI String
uriPathLens :: Lens' URI String
uriPathLens = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URI -> String
uriPath (\URI
parent String
newVal -> URI
parent {uriPath :: String
uriPath = String
newVal})

uriQueryLens :: Lens' URI String
uriQueryLens :: Lens' URI String
uriQueryLens = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URI -> String
uriQuery (\URI
parent String
newVal -> URI
parent {uriQuery :: String
uriQuery = String
newVal})

uriFragmentLens :: Lens' URI String
uriFragmentLens :: Lens' URI String
uriFragmentLens =
  forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens URI -> String
uriFragment (\URI
parent String
newVal -> URI
parent {uriFragment :: String
uriFragment = String
newVal})