[Haskell-cafe] What is the role of $!?

Jules Bean jules at jellybean.co.uk
Mon Dec 10 06:39:38 EST 2007

David Fox wrote:
> Here is a practical example I ran into a few days ago.  With this 
> expression:
>    writeFile path (compute text)
> the file at path would be overwritten with an empty file if an error 
> occurs while evaluating (compute text).  With this one:
>   writeFile path $! (compute text)
> the file alone when an error occurs.

If I understand you correctly, that would be because compute text is 
capable of throwing an exception.

That, then, is the danger of using exceptions in pure code.

Personally I'd use an error-signalling type (like Either) and then this 
wouldn't be an issue.


More information about the Haskell-Cafe mailing list