Hets - the Heterogeneous Tool Set

Copyright(c) T. Mossakowski, C. Maeder, Uni Bremen 2002-2008
LicenseGPLv2 or higher, see LICENSE.txt
MaintainerChristian.Maeder@dfki.de
Stabilityprovisional
Portabilityportable
Safe HaskellSafe-Inferred

Common.Result

Description

Result monad for accumulating Diagnosis messages during analysis phases.

Synopsis

Documentation

data DiagKind

severness of diagnostic messages

Constructors

Error 
Warning 
Hint 
Debug 
MessageW

used for messages in the web interface

mkDiag :: (GetRange a, Pretty a) => DiagKind -> String -> a -> Diagnosis

construct a message for a printable item that carries a position

mkNiceDiag :: (GetRange a, Pretty a) => GlobalAnnos -> DiagKind -> String -> a -> Diagnosis

construct a message for a printable item that carries a position

isErrorDiag :: Diagnosis -> Bool

check whether a diagnosis is an error

hasErrors :: [Diagnosis] -> Bool

Check whether a diagnosis list contains errors

addErrorDiag :: (GetRange a, Pretty a) => String -> a -> Result b -> Result b

add a further error message to explain a failure

checkUniqueness :: (Pretty a, GetRange a, Ord a) => [a] -> [Diagnosis]

A uniqueness check yields errors for duplicates in a given list.

data Result a

The result monad. A failing result should include an error message.

Constructors

Result 

Fields

diags :: [Diagnosis]
 
maybeResult :: Maybe a
 

joinResultWith :: (a -> b -> c) -> Result a -> Result b -> Result c

join two results with a combining function

joinResult :: Result a -> Result b -> Result b

join two results

mapR :: (a -> Result b) -> [a] -> Result [b]

join a list of results that are independently computed

fatal_error :: String -> Range -> Result a

a failing result with a proper position

mkError :: (GetRange a, Pretty a) => String -> a -> Result b

a failing result constructing a message from a type

debug :: (GetRange a, Pretty a) => Int -> (String, a) -> Result ()

add a debug point

plain_error :: a -> String -> Range -> Result a

add an error message but don't fail

warning :: a -> String -> Range -> Result a

add a warning

justWarn :: a -> String -> Result a

just add a warning without position information

hint :: a -> String -> Range -> Result a

add a hint

justHint :: a -> String -> Result a

just add a hint without position information

message :: a -> String -> Result a

add a (web interface) message

maybeToResult :: Range -> String -> Maybe a -> Result a

add a failure message to Nothing

resultToMonad :: Monad m => String -> Result a -> m a

Propagate errors using the error function

resultToMaybe :: Result a -> Maybe a

check whether no errors are present, coerce into Maybe

adjustPos :: Range -> Result a -> Result a

adjust positions of diagnoses

updDiagKind :: (DiagKind -> DiagKind) -> Diagnosis -> Diagnosis

change the diag kind of a diagnosis

propagateErrors :: String -> Result a -> a

Propagate errors using the error function

showErr :: ParseError -> String

showing (Parsec) parse errors using our own showPos function

printDiags :: Int -> [Diagnosis] -> IO ()