
Hi! In Haskell there is difference between throw and throwIO. Because of that I searched for a way to assure ordering in a similar manner of my assertions. But I have not found any. Wouldn't it be useful to have also assertIO counterpart of assert? I would propose "Bool -> IO ()" type. Mitar

On Thu, 24 Feb 2011, Mitar wrote:
In Haskell there is difference between throw and throwIO. Because of that I searched for a way to assure ordering in a similar manner of my assertions. But I have not found any. Wouldn't it be useful to have also assertIO counterpart of assert?
I would propose "Bool -> IO ()" type.
'throw' is for exception handling, 'assert' is for debugging. What do you intend to use 'assert' for? 'assert' is not a combination of 'if' and 'throw'. It can be disabled by a GHC flag, if you think you do not need debugging anymore.

Hi!
On Thu, Feb 24, 2011 at 1:15 AM, Henning Thielemann
'throw' is for exception handling, 'assert' is for debugging. What do you intend to use 'assert' for? 'assert' is not a combination of 'if' and 'throw'. It can be disabled by a GHC flag, if you think you do not need debugging anymore.
Exactly, I need it for debugging. But I would like to have ordering assured when debugging. Mitar

On 24/02/2011 03:28, Mitar wrote:
Hi!
On Thu, Feb 24, 2011 at 1:15 AM, Henning Thielemann
wrote: 'throw' is for exception handling, 'assert' is for debugging. What do you intend to use 'assert' for? 'assert' is not a combination of 'if' and 'throw'. It can be disabled by a GHC flag, if you think you do not need debugging anymore.
Exactly, I need it for debugging. But I would like to have ordering assured when debugging.
I think evaluate (assert ...) is guaranteed to work. Cheers, Simon

Right, assert is designed for pure code. Probably an assert for IO code would also be handy. Cheers, Edward

Hi!
On Fri, Mar 25, 2011 at 5:43 PM, Simon Marlow
I think
evaluate (assert ...)
is guaranteed to work.
I made something like: assertIO :: Bool -> IO () assertIO cond = evaluate (assert cond ()) But the problem is that exception raised have line information of this definition and not of the call itself. Mitar

On 28/03/2011 11:05, Mitar wrote:
Hi!
On Fri, Mar 25, 2011 at 5:43 PM, Simon Marlow
wrote: I think
evaluate (assert ...)
is guaranteed to work.
I made something like:
assertIO :: Bool -> IO () assertIO cond = evaluate (assert cond ())
But the problem is that exception raised have line information of this definition and not of the call itself.
Use Template Haskell, or a CPP macro? Cheers, Simon
participants (4)
-
Edward Z. Yang
-
Henning Thielemann
-
Mitar
-
Simon Marlow