-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Helpers for Control.Exception.assert -- -- GHC supports compile-time toggling of run-time assertions via the -- -fignore-asserts flag, which only effects a behavioural -- change in Control.Exception.assert. Furthermore the reported -- location only gives the use site of the aforementioned, making it -- difficult to abstract over and hence cumbersome to use. -- -- This package aims to make assertions more convenient, and also -- provides a rule to rewrite assertions to id when -- -fignore-asserts is used. @package assert @version 0.0.1.0 module Control.Exception.Assert -- | A distict Exception from AssertionFailed, so that we -- stop fudging the exception message after the first -- mapException. -- -- The name comes from abbreviating ‘assert’ and translating the result -- to my native tongue. newtype Arse Arse :: String -> Arse -- | Generic helper for assert that includes a descriptive message -- to the AssertFailure exception if thrown. Use this to build -- your own assert helpers, such as byOrd. A rule is -- included which rewrites assertMessage to id when -- compiling with -fignore-asserts. assertMessage :: String -> String -> (a -> a) -> a -> a -- | Assert that two values are equal. -- --
-- >>> byEq assert "Bool" False True () -- *** Exception: … Assertion failed "Bool", False ≠ True --byEq :: (Eq x, Show x) => (Bool -> a -> a) -> String -> x -> x -> a -> a -- | Assert that two values obey the given Ordering. -- --
-- >>> byOrd assert "Int" LT 0 1 () -- () --byOrd :: (Ord x, Show x) => (Bool -> a -> a) -> String -> Ordering -> x -> x -> a -> a -- | Assert that a value satisfies the given predicate. -- --
-- >>> byPred assert "Odd" odd 4 () -- *** Exception: … Assertion failed "Odd", 4 --byPred :: Show x => (Bool -> a -> a) -> String -> (x -> Bool) -> x -> a -> a -- | If the first argument evaluates to True, then the result is the -- second argument. Otherwise an AssertionFailed exception is -- raised, containing a String with the source file and line -- number of the call to assert. -- -- Assertions can normally be turned on or off with a compiler flag (for -- GHC, assertions are normally on unless optimisation is turned on with -- -O or the -fignore-asserts option is given). When -- assertions are turned off, the first argument to assert is -- ignored, and the second argument is returned as the result. assert :: Bool -> a -> a instance Typeable Arse instance Exception Arse instance Show Arse