Logo

Programming-Idioms

History of Idiom 123 > diff from v11 to v12

Edit summary for version 12 by jcarr:
New Haskell implementation by user [jcarr]

Version 11

2019-09-26, 22:06:03

Version 12

2019-09-27, 00:57:46

Idiom #123 Assert condition

Verify that predicate isConsistent returns true, otherwise report assertion violation.
Explain if the assertion is executed even in production environment or not.

Idiom #123 Assert condition

Verify that predicate isConsistent returns true, otherwise report assertion violation.
Explain if the assertion is executed even in production environment or not.

Imports
import Control.Exception.Base
Code
let x' = assert isConsistent x
Comments bubble
When x' is evaluted, the condition will be checked and x will be returned.

Disabled for optimized builds or with flag
Doc URL
https://hackage.haskell.org/package/base-4.6.0.1/docs/Control-Exception-Base.html#v:assert