final-pretty-printer-0.1.0.0: Extensible pretty printing with semantic annotations and proportional fonts

Copyright(c) David Darais David Christiansen and Weixi Ma 2016-2017
LicenseMIT
Maintainerdavid.darais@gmail.com
Stabilityexperimental
PortabilityPortable
Safe HaskellNone
LanguageHaskell2010

Text.PrettyPrint.Final.Extensions.Environment

Contents

Description

EnvT extends a pretty printer to track a lexical environment.

Synopsis

Documentation

class (MonadPretty w ann fmt m, MonadReaderEnv env m) => MonadPrettyEnv env w ann fmt m | m -> w, m -> ann, m -> fmt, m -> env Source #

Pretty monads that can read environments. Use this to implement lexical scope in your pretty printer, because the dynamic extent of pretty monad computations typically corresponds to the scope of a binder.

class MonadReaderEnv env m | m -> env where Source #

A reader of environments

Minimal complete definition

askEnv, localEnv

Methods

askEnv :: m env Source #

See ask

localEnv :: (env -> env) -> m a -> m a Source #

See local

Instances

Monad m => MonadReaderEnv env (EnvT env m) Source # 

Methods

askEnv :: EnvT env m env Source #

localEnv :: (env -> env) -> EnvT env m a -> EnvT env m a Source #

The transformer

newtype EnvT env m a Source #

A transformer that adds a reader effect, distinguished by the newtype tag.

Constructors

EnvT 

Fields

Instances

MonadPretty w ann fmt m => MonadPretty w ann fmt (EnvT env m) Source # 
(Monad m, Measure w fmt m) => Measure w fmt (EnvT env m) Source # 

Methods

measure :: Line w fmt -> EnvT env m w Source #

MonadReader r m => MonadReader r (EnvT env m) Source # 

Methods

ask :: EnvT env m r #

local :: (r -> r) -> EnvT env m a -> EnvT env m a #

reader :: (r -> a) -> EnvT env m a #

MonadState s m => MonadState s (EnvT env m) Source # 

Methods

get :: EnvT env m s #

put :: s -> EnvT env m () #

state :: (s -> (a, s)) -> EnvT env m a #

MonadWriter o m => MonadWriter o (EnvT env m) Source # 

Methods

writer :: (a, o) -> EnvT env m a #

tell :: o -> EnvT env m () #

listen :: EnvT env m a -> EnvT env m (a, o) #

pass :: EnvT env m (a, o -> o) -> EnvT env m a #

(Monad m, MonadReaderPrec ann m) => MonadReaderPrec ann (EnvT env m) Source # 

Methods

askPrecEnv :: EnvT env m (PrecEnv ann) Source #

localPrecEnv :: (PrecEnv ann -> PrecEnv ann) -> EnvT env m a -> EnvT env m a Source #

Monad m => MonadReaderEnv env (EnvT env m) Source # 

Methods

askEnv :: EnvT env m env Source #

localEnv :: (env -> env) -> EnvT env m a -> EnvT env m a Source #

MonadTrans (EnvT env) Source # 

Methods

lift :: Monad m => m a -> EnvT env m a #

Monad m => Monad (EnvT env m) Source # 

Methods

(>>=) :: EnvT env m a -> (a -> EnvT env m b) -> EnvT env m b #

(>>) :: EnvT env m a -> EnvT env m b -> EnvT env m b #

return :: a -> EnvT env m a #

fail :: String -> EnvT env m a #

Functor m => Functor (EnvT env m) Source # 

Methods

fmap :: (a -> b) -> EnvT env m a -> EnvT env m b #

(<$) :: a -> EnvT env m b -> EnvT env m a #

Applicative m => Applicative (EnvT env m) Source # 

Methods

pure :: a -> EnvT env m a #

(<*>) :: EnvT env m (a -> b) -> EnvT env m a -> EnvT env m b #

(*>) :: EnvT env m a -> EnvT env m b -> EnvT env m b #

(<*) :: EnvT env m a -> EnvT env m b -> EnvT env m a #

Alternative m => Alternative (EnvT env m) Source # 

Methods

empty :: EnvT env m a #

(<|>) :: EnvT env m a -> EnvT env m a -> EnvT env m a #

some :: EnvT env m a -> EnvT env m [a] #

many :: EnvT env m a -> EnvT env m [a] #

runEnvT :: env -> EnvT env m a -> m a Source #

Run a pretty printer in an initial environment

mapEnvT :: (m a -> n b) -> EnvT env m a -> EnvT env n b Source #

Transform the result of a pretty printer