spoon 0.2 → 0.3
raw patch · 2 files changed
+7/−7 lines, 2 files
Files
- Control/Spoon.hs +6/−6
- spoon.cabal +1/−1
Control/Spoon.hs view
@@ -24,18 +24,18 @@ import System.IO.Unsafe handlers :: [Handler (Maybe a)]-handlers = [ Handler $ \(_ :: ArithException) -> return Nothing- , Handler $ \(_ :: ArrayException) -> return Nothing- , Handler $ \(_ :: ErrorCall) -> return Nothing+handlers = [ Handler $ \(_ :: ArithException) -> return Nothing+ , Handler $ \(_ :: ArrayException) -> return Nothing+ , Handler $ \(_ :: ErrorCall) -> return Nothing , Handler $ \(_ :: PatternMatchFail) -> return Nothing- , Handler $ \(x :: SomeException) -> throwIO x+ , Handler $ \(x :: SomeException) -> throwIO x ] -- | Evaluate a value to normal form and return Nothing if any exceptions are thrown during evaluation. For any error-free value, @spoon = Just@. spoon :: NFData a => a -> Maybe a-spoon a = unsafePerformIO $ (deepseq a (Just `fmap` return a)) `catches` handlers+spoon a = unsafePerformIO $ deepseq a (Just `fmap` return a) `catches` handlers -- | Like 'spoon', but only evaluates to WHNF. teaspoon :: a -> Maybe a-teaspoon a = unsafePerformIO $ (Just `fmap` (return $! a)) `catches` handlers+teaspoon a = unsafePerformIO $ (Just `fmap` evaluate a) `catches` handlers
spoon.cabal view
@@ -1,5 +1,5 @@ name: spoon-version: 0.2+version: 0.3 license: BSD3 license-file: LICENSE author: Matt Morrow, Dan Peebles