Safe Haskell | None |
---|---|
Language | Haskell2010 |
General-purpose utility functions
- data VerificationRes
- = VerSuccess
- | VerFailure !(NonEmpty Text)
- isVerFailure :: VerificationRes -> Bool
- isVerSuccess :: VerificationRes -> Bool
- verResToMonadError :: MonadError e m => (NonEmpty Text -> e) -> VerificationRes -> m ()
- verifyGeneric :: [(Bool, Text)] -> VerificationRes
- formatAllErrors :: NonEmpty Text -> Builder
- formatFirstError :: NonEmpty Text -> Builder
- verResFullF :: VerificationRes -> Builder
- verResSingleF :: VerificationRes -> Builder
Documentation
data VerificationRes Source #
Helpers
isVerFailure :: VerificationRes -> Bool Source #
isVerSuccess :: VerificationRes -> Bool Source #
verResToMonadError :: MonadError e m => (NonEmpty 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
formatAllErrors :: NonEmpty Text -> Builder Source #
Pretty printer for errors from VerFailure, all errors are printed.
formatFirstError :: NonEmpty Text -> Builder Source #
Pretty printer for errors from VerFailure, only first error is printed.
verResFullF :: VerificationRes -> Builder Source #
Format VerificationRes in a pretty way using all errors messages for VerFailure.
verResSingleF :: VerificationRes -> Builder Source #
Format VerificationRes in a pretty way using only first message for VerFailure.