uu-cco-0.1.0.5: Utilities for compiler construction: core functionality

Copyright(c) 2008 Utrecht University
LicenseAll rights reserved
Maintainerstefan@cs.uu.nl
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

CCO.Feedback

Contents

Description

A monad for keeping track of log, warning, and error messages.

Synopsis

Messages

data Message Source

Type of messages. Each Message holds a pretty-printable document in which the text for the message is stored.

Constructors

Log Int Doc

A log message at a specified verbosity level, the default level being 1.

Warning Int Doc

A warning message at a specified severity level, the default level being 1.

Error Doc

An error message.

isError :: Message -> Bool Source

Indicates whether a Message is an Error message.

fromMessage :: Message -> Doc Source

Retrieves the Doc stored in a Message.

The Feedback monad

data Feedback a Source

The Feedback monad. Keeps track of Messages, failing if an Error message is encountered.

trace :: Int -> String -> Feedback () Source

Issues a Log message at a specified verbosity level containing a specified text.

trace_ :: String -> Feedback () Source

Issues a Log message at the default verbosity level 1 containing a specified text.

warn :: Int -> String -> Feedback () Source

Issues a Warning message at a specified severity level containing a specified text.

warn_ :: String -> Feedback () Source

Issues a Warning message at the default severity level 1 containing a specified text.

errorMessage :: Doc -> Feedback a Source

Issues an Error message.

message :: Message -> Feedback () Source

Issues a Message. Fails if an Error message is issued.

messages :: [Message] -> Feedback () Source

Issues a list of Messages. Fails if the list contains an Error message.

wError :: Feedback a -> Feedback a Source

Turns all Warning messages into Error messages.

succeeding :: Feedback a -> Bool Source

Retrieves whether a Feedback computation will succeed.

failing :: Feedback a -> Bool Source

Retrieves whether a Feedback computation will fail.

runFeedback :: Feedback a -> Int -> Int -> Handle -> IO (Maybe a) Source

Runs a Feedback computation at a specified verbosity and severity level, pretty printing messages onto a specified Handle.