Copyright | (c) T. Mossakowski C. Maeder Uni Bremen 2002-2008 |
---|---|
License | GPLv2 or higher, see LICENSE.txt |
Maintainer | Christian.Maeder@dfki.de |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe |
Synopsis
- data DiagKind
- data Diagnosis = Diag {
- diagKind :: DiagKind
- diagString :: String
- diagPos :: Range
- mkDiag :: (GetRange a, Pretty a) => DiagKind -> String -> a -> Diagnosis
- mkNiceDiag :: (GetRange a, Pretty a) => GlobalAnnos -> DiagKind -> String -> a -> Diagnosis
- isErrorDiag :: Diagnosis -> Bool
- hasErrors :: [Diagnosis] -> Bool
- addErrorDiag :: (GetRange a, Pretty a) => String -> a -> Result b -> Result b
- checkUniqueness :: (Pretty a, GetRange a, Ord a) => [a] -> [Diagnosis]
- data Result a = Result {
- diags :: [Diagnosis]
- maybeResult :: Maybe a
- appendDiags :: [Diagnosis] -> Result ()
- joinResultWith :: (a -> b -> c) -> Result a -> Result b -> Result c
- joinResult :: Result a -> Result b -> Result b
- mapR :: (a -> Result b) -> [a] -> Result [b]
- fatal_error :: String -> Range -> Result a
- mkError :: (GetRange a, Pretty a) => String -> a -> Result b
- debug :: (GetRange a, Pretty a) => Int -> (String, a) -> Result ()
- plain_error :: a -> String -> Range -> Result a
- warning :: a -> String -> Range -> Result a
- justWarn :: a -> String -> Result a
- hint :: a -> String -> Range -> Result a
- justHint :: a -> String -> Result a
- message :: a -> String -> Result a
- maybeToResult :: Range -> String -> Maybe a -> Result a
- resultToMonad :: MonadFail m => String -> Result a -> m a
- resultToMaybe :: Result a -> Maybe a
- adjustPos :: Range -> Result a -> Result a
- updDiagKind :: (DiagKind -> DiagKind) -> Diagnosis -> Diagnosis
- propagateErrors :: String -> Result a -> a
- showErr :: ParseError -> String
- prettyRange :: [Pos] -> Doc
- filterDiags :: Int -> [Diagnosis] -> [Diagnosis]
- showRelDiags :: Int -> [Diagnosis] -> String
- printDiags :: Int -> [Diagnosis] -> IO ()
Documentation
severness of diagnostic messages
Instances
Eq DiagKind Source # | |
Data DiagKind Source # | |
Defined in Common.Result 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 :: forall r r'. (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 # | |
Show DiagKind Source # | |
Generic DiagKind | |
FromJSON DiagKind | |
Defined in ATC.Result parseJSON :: Value -> Parser DiagKind parseJSONList :: Value -> Parser [DiagKind] | |
ToJSON DiagKind | |
Defined in ATC.Result toEncoding :: DiagKind -> Encoding toJSONList :: [DiagKind] -> Value toEncodingList :: [DiagKind] -> Encoding | |
ShATermConvertible DiagKind | |
Defined in ATC.Result toShATermAux :: ATermTable -> DiagKind -> IO (ATermTable, Int) toShATermList' :: ATermTable -> [DiagKind] -> IO (ATermTable, Int) fromShATermAux :: Int -> ATermTable -> (ATermTable, DiagKind) fromShATermList' :: Int -> ATermTable -> (ATermTable, [DiagKind]) | |
type Rep DiagKind | |
Defined in ATC.Result type Rep DiagKind = D1 ('MetaData "DiagKind" "Common.Result" "main" 'False) ((C1 ('MetaCons "Error" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Warning" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Hint" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Debug" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MessageW" 'PrefixI 'False) (U1 :: Type -> Type)))) |
a diagnostic message with Pos
Instances
Eq Diagnosis Source # | |
Data Diagnosis Source # | |
Defined in Common.Result 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 :: forall r r'. (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 # | |
Generic Diagnosis | |
GetRange Diagnosis Source # | |
FromJSON Diagnosis | |
Defined in ATC.Result parseJSON :: Value -> Parser Diagnosis parseJSONList :: Value -> Parser [Diagnosis] | |
ToJSON Diagnosis | |
Defined in ATC.Result toEncoding :: Diagnosis -> Encoding toJSONList :: [Diagnosis] -> Value toEncodingList :: [Diagnosis] -> Encoding | |
ShATermConvertible Diagnosis | |
Defined in ATC.Result toShATermAux :: ATermTable -> Diagnosis -> IO (ATermTable, Int) toShATermList' :: ATermTable -> [Diagnosis] -> IO (ATermTable, Int) fromShATermAux :: Int -> ATermTable -> (ATermTable, Diagnosis) fromShATermList' :: Int -> ATermTable -> (ATermTable, [Diagnosis]) | |
Pretty Diagnosis Source # | |
type Rep Diagnosis | |
Defined in ATC.Result type Rep Diagnosis = D1 ('MetaData "Diagnosis" "Common.Result" "main" 'False) (C1 ('MetaCons "Diag" 'PrefixI 'True) (S1 ('MetaSel ('Just "diagKind") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiagKind) :*: (S1 ('MetaSel ('Just "diagString") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "diagPos") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Range)))) |
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
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.
The result monad. A failing result should include an error message.
Result | |
|
Instances
Monad Result Source # | |
Functor Result Source # | |
MonadFail Result Source # | |
Defined in Common.Result | |
Applicative Result Source # | |
Alternative Result Source # | |
MonadPlus Result Source # | |
Data a => Data (Result a) Source # | |
Defined in Common.Result 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 :: forall r r'. (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 # | |
Generic (Result a) | |
FromJSON a => FromJSON (Result a) | |
Defined in ATC.Result parseJSON :: Value -> Parser (Result a) parseJSONList :: Value -> Parser [Result a] | |
ToJSON a => ToJSON (Result a) | |
Defined in ATC.Result toEncoding :: Result a -> Encoding toJSONList :: [Result a] -> Value toEncodingList :: [Result a] -> Encoding | |
ShATermConvertible a => ShATermConvertible (Result a) | |
Defined in ATC.Result toShATermAux :: ATermTable -> Result a -> IO (ATermTable, Int) toShATermList' :: ATermTable -> [Result a] -> IO (ATermTable, Int) fromShATermAux :: Int -> ATermTable -> (ATermTable, Result a) fromShATermList' :: Int -> ATermTable -> (ATermTable, [Result a]) | |
Pretty a => Pretty (Result a) Source # | |
type Rep (Result a) | |
Defined in ATC.Result type Rep (Result a) = D1 ('MetaData "Result" "Common.Result" "main" 'False) (C1 ('MetaCons "Result" 'PrefixI 'True) (S1 ('MetaSel ('Just "diags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Diagnosis]) :*: S1 ('MetaSel ('Just "maybeResult") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe a)))) |
appendDiags :: [Diagnosis] -> Result () Source #
joinResultWith :: (a -> b -> c) -> Result a -> Result b -> Result c Source #
join two results with a combining function
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
plain_error :: a -> String -> Range -> Result a Source #
add an error message but don't fail
maybeToResult :: Range -> String -> Maybe a -> Result a Source #
add a failure message to Nothing
resultToMonad :: MonadFail 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
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
prettyRange :: [Pos] -> Doc Source #
filterDiags :: Int -> [Diagnosis] -> [Diagnosis] Source #
showRelDiags :: Int -> [Diagnosis] -> String Source #
printDiags :: Int -> [Diagnosis] -> IO () Source #