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

Common.Result

Contents

Description

Result monad for accumulating Diagnosis messages during analysis phases.

Synopsis

Documentation

data DiagKind Source #

severness of diagnostic messages

Constructors

Error 
Warning 
Hint 
Debug 
MessageW

used for messages in the web interface

Instances

Eq DiagKind Source # 

Methods

(==) :: DiagKind -> DiagKind -> Bool

(/=) :: DiagKind -> DiagKind -> Bool

Data DiagKind Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DiagKind -> c DiagKind

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DiagKind

toConstr :: DiagKind -> Constr

dataTypeOf :: DiagKind -> DataType

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c DiagKind)

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DiagKind)

gmapT :: (forall b. Data b => b -> b) -> DiagKind -> DiagKind

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DiagKind -> r

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DiagKind -> r

gmapQ :: (forall d. Data d => d -> u) -> DiagKind -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> DiagKind -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> DiagKind -> m DiagKind

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DiagKind -> m DiagKind

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DiagKind -> m DiagKind

Ord DiagKind Source # 

Methods

compare :: DiagKind -> DiagKind -> Ordering

(<) :: DiagKind -> DiagKind -> Bool

(<=) :: DiagKind -> DiagKind -> Bool

(>) :: DiagKind -> DiagKind -> Bool

(>=) :: DiagKind -> DiagKind -> Bool

max :: DiagKind -> DiagKind -> DiagKind

min :: DiagKind -> DiagKind -> DiagKind

Show DiagKind Source # 

Methods

showsPrec :: Int -> DiagKind -> ShowS

show :: DiagKind -> String

showList :: [DiagKind] -> ShowS

data Diagnosis Source #

a diagnostic message with Pos

Constructors

Diag 

Fields

Instances

Eq Diagnosis Source # 

Methods

(==) :: Diagnosis -> Diagnosis -> Bool

(/=) :: Diagnosis -> Diagnosis -> Bool

Data Diagnosis Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Diagnosis -> c Diagnosis

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Diagnosis

toConstr :: Diagnosis -> Constr

dataTypeOf :: Diagnosis -> DataType

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Diagnosis)

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Diagnosis)

gmapT :: (forall b. Data b => b -> b) -> Diagnosis -> Diagnosis

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Diagnosis -> r

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Diagnosis -> r

gmapQ :: (forall d. Data d => d -> u) -> Diagnosis -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> Diagnosis -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Diagnosis -> m Diagnosis

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Diagnosis -> m Diagnosis

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Diagnosis -> m Diagnosis

Show Diagnosis Source # 

Methods

showsPrec :: Int -> Diagnosis -> ShowS

show :: Diagnosis -> String

showList :: [Diagnosis] -> ShowS

GetRange Diagnosis Source # 
Pretty Diagnosis Source # 

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

construct a message for a printable item that carries a position

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

construct a message for a printable item that carries a position

isErrorDiag :: Diagnosis -> Bool Source #

check whether a diagnosis is an error

hasErrors :: [Diagnosis] -> Bool Source #

Check whether a diagnosis list contains errors

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

add a further error message to explain a failure

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

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

data Result a Source #

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

Constructors

Result 

Fields

Instances

Monad Result Source # 

Methods

(>>=) :: Result a -> (a -> Result b) -> Result b

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

return :: a -> Result a

fail :: String -> Result a

Functor Result Source # 

Methods

fmap :: (a -> b) -> Result a -> Result b

(<$) :: a -> Result b -> Result a

Applicative Result Source # 

Methods

pure :: a -> Result a

(<*>) :: Result (a -> b) -> Result a -> Result b

(*>) :: Result a -> Result b -> Result b

(<*) :: Result a -> Result b -> Result a

MonadPlus Result Source # 

Methods

mzero :: Result a

mplus :: Result a -> Result a -> Result a

Alternative Result Source # 

Methods

empty :: Result a

(<|>) :: Result a -> Result a -> Result a

some :: Result a -> Result [a]

many :: Result a -> Result [a]

Data a => Data (Result a) Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Result a -> c (Result a)

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Result a)

toConstr :: Result a -> Constr

dataTypeOf :: Result a -> DataType

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Result a))

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Result a))

gmapT :: (forall b. Data b => b -> b) -> Result a -> Result a

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Result a -> r

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Result a -> r

gmapQ :: (forall d. Data d => d -> u) -> Result a -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> Result a -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Result a -> m (Result a)

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Result a -> m (Result a)

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Result a -> m (Result a)

Show a => Show (Result a) Source # 

Methods

showsPrec :: Int -> Result a -> ShowS

show :: Result a -> String

showList :: [Result a] -> ShowS

Pretty a => Pretty (Result a) Source # 

Methods

pretty :: Result a -> Doc Source #

pretties :: [Result a] -> Doc Source #

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

join two results with a combining function

joinResult :: Result a -> Result b -> Result b Source #

join two results

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

join a list of results that are independently computed

fatal_error :: String -> Range -> Result a Source #

a failing result with a proper position

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

a failing result constructing a message from a type

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

add a debug point

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

add an error message but don't fail

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

add a warning

justWarn :: a -> String -> Result a Source #

just add a warning without position information

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

add a hint

justHint :: a -> String -> Result a Source #

just add a hint without position information

message :: a -> String -> Result a Source #

add a (web interface) message

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

add a failure message to Nothing

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

Propagate errors using the error function

resultToMaybe :: Result a -> Maybe a Source #

check whether no errors are present, coerce into Maybe

adjustPos :: Range -> Result a -> Result a Source #

adjust positions of diagnoses

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

change the diag kind of a diagnosis

propagateErrors :: String -> Result a -> a Source #

Propagate errors using the error function

showErr :: ParseError -> String Source #

showing (Parsec) parse errors using our own showPos function

showRelDiags :: Int -> [Diagnosis] -> String Source #

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

Orphan instances