Copyright | (c) David Darais David Christiansen and Weixi Ma 2016-2017 |
---|---|
License | MIT |
Maintainer | david.darais@gmail.com |
Stability | experimental |
Portability | Portable |
Safe Haskell | None |
Language | Haskell2010 |
A transformer of pretty monads that provides effects for inserting parentheses minimally and correctly.
- data PrecEnv ann = PrecEnv {}
- precEnv0 :: PrecEnv ann
- askLevel :: (Functor m, MonadReaderPrec ann m) => m Int
- localLevel :: (Functor m, MonadReaderPrec ann m) => (Int -> Int) -> m a -> m a
- infl :: MonadPrettyPrec w ann fmt m => Int -> m () -> m () -> m () -> m ()
- infr :: MonadPrettyPrec w ann fmt m => Int -> m () -> m () -> m () -> m ()
- atLevel :: MonadPrettyPrec w ann fmt m => Int -> m () -> m ()
- botLevel :: MonadPrettyPrec w ann fmt m => m () -> m ()
- app :: MonadPrettyPrec w ann fmt m => m () -> [m ()] -> m ()
- askBumped :: (Functor m, MonadReaderPrec ann m) => m Bool
- class MonadReaderPrec ann m | m -> ann where
- class (MonadPretty w ann fmt m, MonadReaderPrec ann m) => MonadPrettyPrec w ann fmt m | m -> w, m -> ann, m -> fmt
- newtype PrecT ann m a = PrecT {}
- runPrecT :: PrecEnv ann -> PrecT ann m a -> m a
- mapPrecT :: (m a -> n b) -> PrecT ann m a -> PrecT ann n b
Precedence information
A precedence environment contains enough information to determine whether parentheses should be inserted.
PrecEnv | |
|
precEnv0 :: PrecEnv ann Source #
An initial precedence environment that works for languages with parentheses as delimiters.
Precedence effects
askLevel :: (Functor m, MonadReaderPrec ann m) => m Int Source #
What is the current precedence level?
localLevel :: (Functor m, MonadReaderPrec ann m) => (Int -> Int) -> m a -> m a Source #
Run a subcomputation with a modified precedence level.
infl :: MonadPrettyPrec w ann fmt m => Int -> m () -> m () -> m () -> m () Source #
Display a left-associative infix operator at a precedence level
infr :: MonadPrettyPrec w ann fmt m => Int -> m () -> m () -> m () -> m () Source #
Display a right-associative infix operator at a precedence level
atLevel :: MonadPrettyPrec w ann fmt m => Int -> m () -> m () Source #
Run a subcomputation at a particular precedence level
botLevel :: MonadPrettyPrec w ann fmt m => m () -> m () Source #
Put a subdocument in the lowest precedence context
app :: MonadPrettyPrec w ann fmt m => m () -> [m ()] -> m () Source #
Perform function application with precedence level <100
askBumped :: (Functor m, MonadReaderPrec ann m) => m Bool Source #
Is the current precedence bumped? See PrecEnv
.
The transformer
class MonadReaderPrec ann m | m -> ann where Source #
Precedence follows the structure of a document, so a Reader provides the appropriate dynamic extent of precedence information.
askPrecEnv :: m (PrecEnv ann) Source #
What is the current precedence environment? (see ask
)
localPrecEnv :: (PrecEnv ann -> PrecEnv ann) -> m a -> m a Source #
Override the precedence environment in a subcomputation. (see local
)
Monad m => MonadReaderPrec ann (PrecT ann m) Source # | |
(Monad m, MonadReaderPrec ann m) => MonadReaderPrec ann (EnvT env m) Source # | |
class (MonadPretty w ann fmt m, MonadReaderPrec ann m) => MonadPrettyPrec w ann fmt m | m -> w, m -> ann, m -> fmt Source #
A pretty monad that can read precedence environments
newtype PrecT ann m a Source #
A monad transformer that adds a precedence effects
MonadReader r m => MonadReader r (PrecT ann m) Source # | |
MonadState s m => MonadState s (PrecT ann m) Source # | |
MonadWriter o m => MonadWriter o (PrecT ann m) Source # | |
Monad m => MonadReaderPrec ann (PrecT ann m) Source # | |
MonadTrans (PrecT ann) Source # | |
Monad m => Monad (PrecT ann m) Source # | |
Functor m => Functor (PrecT ann m) Source # | |
Applicative m => Applicative (PrecT ann m) Source # | |
Alternative m => Alternative (PrecT ann m) Source # | |