Safe Haskell | None |
---|---|
Language | GHC2021 |
Runtime assertion utility.
Example
>>>
let !_ = runtimeAssert False "errorMessage"
*** Exception: errorMessage ...>>>
let !_ = checkIndex "AtCoder.Internal.Assert.test" 0 3
>>>
let !_ = checkIndex "AtCoder.Internal.Assert.test" (-1) 3
*** Exception: AtCoder.Internal.Assert.test: given invalid index `-1` over length `3` ...>>>
let !_ = checkVertex "AtCoder.Internal.Assert.test" 0 3
>>>
let !_ = checkVertex "AtCoder.Internal.Assert.test" (-1) 3
*** Exception: AtCoder.Internal.Assert.test: given invalid vertex `-1` over the number of vertices `3` ...>>>
let !_ = checkEdge "AtCoder.Internal.Assert.test" 0 3
>>>
let !_ = checkEdge "AtCoder.Internal.Assert.test" (-1) 3
*** Exception: AtCoder.Internal.Assert.test: given invalid edge index `-1` over the number of edges `3` ...>>>
let !_ = checkCustom "AtCoder.Internal.Assert.test" "index" 0 "set" 3
>>>
let !_ = checkCustom "AtCoder.Internal.Assert.test" "index" (-1) "set" 3
*** Exception: AtCoder.Internal.Assert.test: given invalid index `-1` over set `3` ...>>>
let !_ = checkInterval "AtCoder.Internal.Assert.test" 0 3 3
>>>
let !_ = checkInterval "AtCoder.Internal.Assert.test" 0 4 3
*** Exception: AtCoder.Internal.Assert.test: given invalid interval `[0, 4)` over length `3` ...
Since: 1.0.0
Synopsis
- runtimeAssert :: HasCallStack => Bool -> String -> ()
- checkIndex :: HasCallStack => String -> Int -> Int -> ()
- checkVertex :: HasCallStack => String -> Int -> Int -> ()
- checkEdge :: HasCallStack => String -> Int -> Int -> ()
- checkCustom :: HasCallStack => String -> String -> Int -> String -> Int -> ()
- checkInterval :: HasCallStack => String -> Int -> Int -> Int -> ()
Runtime assertion
runtimeAssert :: HasCallStack => Bool -> String -> () #
\(O(1)\) Assertion that is never erased at compile time.
Since: 1.0.0
Index assertions
checkIndex :: HasCallStack => String -> Int -> Int -> () #
\(O(1)\) Asserts \(0 \leq i \lt n\) for an array index \(i\).
Since: 1.0.0
checkVertex :: HasCallStack => String -> Int -> Int -> () #
\(O(1)\) Asserts \(0 \leq i \lt n\) for a graph vertex \(i\).
Since: 1.0.0
checkEdge :: HasCallStack => String -> Int -> Int -> () #
\(O(1)\) Asserts \(0 \leq i \lt m\) for an edge index \(i\).
Since: 1.0.0
checkCustom :: HasCallStack => String -> String -> Int -> String -> Int -> () #
\(O(1)\) Asserts \(0 \leq i \lt n\) with custom index/set names.
Since: 1.0.0
Interval assertion
checkInterval :: HasCallStack => String -> Int -> Int -> Int -> () #
\(O(1)\) Asserts \(0 \leq l \leq r \leq n\) for a half-open interval \([l, r)\).
Since: 1.0.0