module Unwitch.TryEvaluate ( tryEvaluate ) where import Control.Exception (Exception, evaluate, try) import System.IO.Unsafe (unsafePerformIO) tryEvaluate :: Exception e => a -> Either e a tryEvaluate :: forall e a. Exception e => a -> Either e a tryEvaluate = IO (Either e a) -> Either e a forall a. IO a -> a unsafePerformIO (IO (Either e a) -> Either e a) -> (a -> IO (Either e a)) -> a -> Either e a forall b c a. (b -> c) -> (a -> b) -> a -> c . IO a -> IO (Either e a) forall e a. Exception e => IO a -> IO (Either e a) try (IO a -> IO (Either e a)) -> (a -> IO a) -> a -> IO (Either e a) forall b c a. (b -> c) -> (a -> b) -> a -> c . a -> IO a forall a. a -> IO a evaluate {-# NOINLINE tryEvaluate #-}