Safe Haskell | None |
---|---|
Language | Haskell2010 |
General-purpose utility functions
- data VerificationRes
- = VerSuccess
- | VerFailure ![Text]
- isVerFailure :: VerificationRes -> Bool
- isVerSuccess :: VerificationRes -> Bool
- verResToMonadError :: MonadError e m => ([Text] -> e) -> VerificationRes -> m ()
- verifyGeneric :: [(Bool, Text)] -> VerificationRes
- buildVerResFull :: VerificationRes -> Builder
- buildVerResSingle :: VerificationRes -> Builder
- formatAllErrors :: [Text] -> Text
- formatFirstError :: [Text] -> Text
- verResFullF :: Format r (VerificationRes -> r)
- verResSingleF :: Format r (VerificationRes -> r)
Documentation
data VerificationRes Source #
Helpers
isVerFailure :: VerificationRes -> Bool Source #
isVerSuccess :: VerificationRes -> Bool Source #
verResToMonadError :: MonadError e m => ([Text] -> e) -> VerificationRes -> m () Source #
Verification
verifyGeneric :: [(Bool, Text)] -> VerificationRes Source #
This function takes list of (predicate, message) pairs and checks each predicate. If predicate is False it's considered an error. If there is at least one error this function returns VerFailure, otherwise VerSuccess is returned. It's useful to verify some data before using it. Example usage: `verifyGeneric [(checkA, "A is bad"), (checkB, "B is bad")]`
Prety printing
buildVerResFull :: VerificationRes -> Builder Source #
Format VerificationRes in a pretty way using all errors messages for VerFailure.
buildVerResSingle :: VerificationRes -> Builder Source #
Format VerificationRes in a pretty way using only first message for VerFailure.
formatAllErrors :: [Text] -> Text Source #
Pretty printer for errors from VerFailure, all errors are printed.
formatFirstError :: [Text] -> Text Source #
Pretty printer for errors from VerFailure, only first error is printed.
verResFullF :: Format r (VerificationRes -> r) Source #
Formatter based on buildVerResFull.
verResSingleF :: Format r (VerificationRes -> r) Source #
Formatter based on buildVerResSingle.