module Unbound.Generics.LocallyNameless.Internal.Lens where

import Control.Monad.Reader (MonadReader(..))
import qualified Control.Monad.Reader as Reader
import Control.Applicative (Const(..))

type Getting r s a = (a -> Const r a) -> s -> Const r s

view :: MonadReader s m => Getting a s a -> m a
view :: forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting a s a
l = (s -> a) -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
Reader.asks (Const a s -> a
forall {k} a (b :: k). Const a b -> a
getConst (Const a s -> a) -> (s -> Const a s) -> s -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting a s a
l a -> Const a a
forall {k} a (b :: k). a -> Const a b
Const)
{-# INLINE view #-}