[Haskell-cafe] Re: ANNOUNCE: HNOP 0.1

Bjorn Bringert bringert at cs.chalmers.se
Sat Jul 1 00:20:58 EDT 2006

On Jun 30, 2006, at 2:52 PM, Ashley Yakeley wrote:

> Simon Marlow wrote:
>> My congratulations to the development team; this is an important  
>> contribution to the community.
> Thanks!
>> You might want to use {-# OPTIONS_GHC #-} rather than {-# OPTIONS  
>> #-}, unless compatibility with older versions of GHC is a goal.   
>> Still, the pragma only turns on warnings, so it's harmless.
> Applied, thanks. At some point I want to do equivalent things for  
> other compilers. I generally like to be pretty strict about  
> warnings, especially as one can selectively disable them if needed.
>>   noop :: IO ()  -- generalise to other Monads?
>> Only IO makes sense really, since by definition every non-IO  
>> expression does nothing, so the only interesting way to do nothing  
>> is in the IO monad.
> Agreed. The concept of "doing nothing" is best understood within  
> the conceptual domain of "doing things" in the IO sense. I shall  
> also be resisting any calls for an unsafe version (unsafeNoOp :: ()).
> I'm currently considering possible unit tests, since right now I  
> rely solely on code inspection. One possibility would be to simply  
> time the function to show that it didn't have time to do anything  
> really long at least. But that's not very satisfactory, since that  
> is strictly a performance test, not a functionality test. It's like  
> any other Haskell function: I want to implement it as efficiently  
> as possible, but I don't guarantee any particular performance.
> Ideally I would have tests like these:
> * Verify noop does nothing with the file system.
> * Verify noop does no networking activity.
> * Verify noop makes no use of stdin/stdout/stderr.
> * Verify noop does not modify any external IORefs.
> etc.
> Actually, I think the fourth one may be unnecessary, given that we  
> don't have global mutable state. The third might not be too hard.  
> It's not clear how to do the others, however. I should hate to  
> discover that a bug in my implementation was accidentally causing  
> it to behave as a secure distributed HTTP-addressable digital media  
> semantic content management system.

You may also want to verify that nothing is actually returned. What  
if there is a bug that makes it return bottom instead of nothing?  
This would mean that it would work fine for simple uses like your  
example run, but could crash your program if it actually uses the  
nothing (for example if HNOP is converted to a library as suggested  
by others).

I guess this is related to the issue of exception handling. What if  
the program is interrupted when it's halfway through doing nothing?  
Ideally we would like to guarantee that it does nothing atomically.


More information about the Haskell-Cafe mailing list