{-# LANGUAGE RankNTypes #-} {-# OPTIONS_HADDOCK hide #-} module Network.HTTP.Client.Lens.Internal where import Control.Applicative import Control.Exception (Exception(..), SomeException) import Data.Profunctor (Profunctor(..), Choice(..)) type Prism s t a b = forall p f. (Choice p, Applicative f) => p a (f b) -> p s (f t) type Prism' s a = Prism s s a a 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 view :: Lens' s a -> s -> a view :: forall s a. Lens' s a -> s -> a view Lens' s a l = forall {k} a (b :: k). Const a b -> a getConst forall b c a. (b -> c) -> (a -> b) -> a -> c . Lens' s a l forall {k} a (b :: k). a -> Const a b Const {-# INLINE view #-} prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b prism :: forall b t s a. (b -> t) -> (s -> Either t a) -> Prism s t a b prism b -> t bt s -> Either t a seta = forall (p :: * -> * -> *) a b c d. Profunctor p => (a -> b) -> (c -> d) -> p b c -> p a d dimap s -> Either t a seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c either forall (f :: * -> *) a. Applicative f => a -> f a pure (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap b -> t bt)) forall b c a. (b -> c) -> (a -> b) -> a -> c . forall (p :: * -> * -> *) a b c. Choice p => p a b -> p (Either c a) (Either c b) right' {-# INLINE prism #-} prism' :: (b -> s) -> (s -> Maybe a) -> Prism s s a b prism' :: forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b prism' b -> s bs s -> Maybe a sma = forall b t s a. (b -> t) -> (s -> Either t a) -> Prism s t a b prism b -> s bs (\s s -> forall b a. b -> (a -> b) -> Maybe a -> b maybe (forall a b. a -> Either a b Left s s) forall a b. b -> Either a b Right (s -> Maybe a sma s s)) {-# INLINE prism' #-} exception :: Exception a => Prism' SomeException a exception :: forall a. Exception a => Prism' SomeException a exception = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b prism' forall e. Exception e => e -> SomeException toException forall e. Exception e => SomeException -> Maybe e fromException {-# INLINE exception #-} infixl 1 <&> (<&>) :: Functor f => f a -> (a -> b) -> f b <&> :: forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b (<&>) = forall a b c. (a -> b -> c) -> b -> a -> c flip forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap {-# INLINE (<&>) #-}