fail package:base

Transitional module providing the MonadFail class and primitive instances. This module can be imported for defining forward compatible MonadFail instances:
import qualified Control.Monad.Fail as Fail

instance Monad Foo where
(>>=) = {- ...bind impl... -}

-- Provide legacy fail implementation for when
-- new-style MonadFail desugaring is not enabled.
fail = Fail.fail

instance Fail.MonadFail Foo where
fail = {- ...fail implementation... -}
See https://gitlab.haskell.org/haskell/prime/-/wikis/libraries/proposals/monad-fail for more details.
Types for specifying how text encoding/decoding fails
When a value is bound in do-notation, the pattern on the left hand side of <- might not match. In this case, this class provides a function to recover. A Monad without a MonadFail instance may only be used in conjunction with pattern that always match, such as newtypes, tuples, data types with only a single data constructor, and irrefutable patterns (~pat). Instances of MonadFail should satisfy the following law: fail s should be a left zero for >>=,
fail s >>= f  =  fail s
If your Monad is also MonadPlus, a popular definition is
fail _ = mzero
fail s should be an action that runs in the monad itself, not an exception (except in instances of MonadIO). In particular, fail should not be implemented in terms of error.
assert was applied to False.
Compaction found an object that cannot be compacted. Functions cannot be compacted, nor can mutable objects or pinned objects. See compact.
A pattern match failed. The String gives information about the source location of the pattern.
indicates program failure with an exit code. The exact interpretation of the code is operating-system dependent. In particular, some values may be prohibited (e.g. 0 on a POSIX-compliant system).
The computation exitFailure is equivalent to exitWith (ExitFailure exitfail), where exitfail is implementation-dependent.
Always fails.
Always fails.
The CodingFailureMode is used to construct TextEncodings, and specifies how they handle illegal sequences.
Throw an error when an illegal sequence is encountered
Attempt to ignore and recover if an illegal sequence is encountered
Use the private-use escape mechanism to attempt to allow illegal sequences to be roundtripped.
Replace with the closest visual match upon an illegal sequence