orome
orome

Reputation: 48506

Is there a way to leave 'assert' enabled in my Hackage package?

I have a Haskell package in which I perform some checks using assert, but when my package is built on clients' machines, these are generally — because of, I gather, optimizations — turned into no-ops.

Is there a way to persevere assert my Hackage package when it is installed on others' machines; or perhaps an alternate approach I can use with the same effect?

Upvotes: 3

Views: 81

Answers (1)

dfeuer
dfeuer

Reputation: 48611

If you want to, you can specify -fno-ignore-asserts. This is probably best done per-file, with a pragma:

{-# OPTIONS_GHC -fno-ignore-asserts #-}

You really shouldn't leave assertions active in any module that uses them in anything that could potentially be used in a tight loop.

Upvotes: 6

Related Questions