{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
module Text.PrettyBy.Monad
( HasPrettyConfig (..)
, MonadPretty
, prettyM
, displayM
) where
import Text.Pretty
import Text.PrettyBy.Default
import Text.PrettyBy.Internal
import Text.PrettyBy.Internal.Utils
import Control.Monad.Reader
import Lens.Micro
class HasPrettyConfig env config | env -> config where
prettyConfig :: Lens' env config
type MonadPretty config env m = (MonadReader env m, HasPrettyConfig env config)
prettyM :: (MonadPretty config env m, PrettyBy config a) => a -> m (Doc ann)
prettyM :: forall config env (m :: * -> *) a ann.
(MonadPretty config env m, PrettyBy config a) =>
a -> m (Doc ann)
prettyM a
x = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall config a ann. PrettyBy config a => config -> a -> Doc ann
prettyBy a
x forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall env config. HasPrettyConfig env config => Lens' env config
prettyConfig
displayM
:: forall str a m env config. (MonadPretty config env m, PrettyBy config a, Render str)
=> a -> m str
displayM :: forall str a (m :: * -> *) env config.
(MonadPretty config env m, PrettyBy config a, Render str) =>
a -> m str
displayM = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall str ann. Render str => Doc ann -> str
render forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall config env (m :: * -> *) a ann.
(MonadPretty config env m, PrettyBy config a) =>
a -> m (Doc ann)
prettyM