-- editorconfig-checker-disable-file
-- | Utils used internally.

module Text.PrettyBy.Internal.Utils
    ( view
    ) where

import Control.Monad.Reader
import Data.Functor.Const
import Lens.Micro
import Lens.Micro.Internal ((#.))

-- | An inlined https://hackage.haskell.org/package/microlens-mtl-0.2.0.1/docs/Lens-Micro-Mtl.html#v:view
-- (just not to depend on this package).
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
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 c b a. Coercible c b => (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 #-}