Reputation: 23135
I've written the following function:
staticAssert :: Bool -> Q [Dec]
staticAssert cond = case cond of
True -> return []
False -> fail "staticAssert failed"
Basically this evaluates condition at compile time and if it is false causes a compile error.
However, what I would like for staticAssert
to instead of outputting "staticAssert failed", output the expression that failed the assertion.
Upvotes: 2
Views: 270