« Mixed feelings | Main | lambda.pm »

'raises' predicate (Haskell)

A Haskell predicate that tests whether an expression raises an error (for my future reference):

import Control.Exception

raises :: a -> IO Bool
raises expr = 
   Control.Exception.catch (
      return . (const False) =<< Control.Exception.evaluate expr
   ) (return . (const True))

Post a comment