verigraph-1.1.1: Software specification and verification tool based on graph rewriting.

Safe HaskellSafe
LanguageHaskell2010

Abstract.Valid

Synopsis

Documentation

class Valid a where Source #

Type class for types that admit "malformed" values, and must thus be checked.

Although implementing the isValid method is sufficient, it will result in poor error messages. Therefore, implementing the validate method is recommended.

Minimal complete definition

isValid | validate

Methods

isValid :: a -> Bool Source #

Checks if the given value is well-formed

validate :: a -> ValidationResult Source #

Checks if the given value is well-formed, providing an explanation of any errors encountered.

ensure :: Bool -> String -> ValidationResult Source #

Return IsValid if the given boolean is true, otherwise return IsInvalid with the given error message.

withContext :: String -> ValidationResult -> ValidationResult Source #

Prepends the indication of context to any error messages produced by the validation result.

errorMessages :: ValidationResult -> Maybe String Source #

Obtains the error messages produced by validation, or Nothing if no error was found

validateNamed :: Valid a => (name -> String) -> [(name, a)] -> ValidationResult Source #

Validates a list of named values, modifying their names with the given function.

ensureValid :: ValidationResult -> IO () Source #

If the given validation detected some error, prints the error out and exits with failure.