From d80b16fe827d871ec26423fd827d8bf6d3d00513 Mon Sep 17 00:00:00 2001 From: Valentin Robert Date: Mon, 7 Aug 2023 23:16:36 -0700 Subject: [PATCH] small simplification --- src/Reopt/Utils/Exit.hs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Reopt/Utils/Exit.hs b/src/Reopt/Utils/Exit.hs index 90935304..8ec65fae 100644 --- a/src/Reopt/Utils/Exit.hs +++ b/src/Reopt/Utils/Exit.hs @@ -11,6 +11,7 @@ where import Control.Exception (catch) import Control.Monad.Except (ExceptT, runExceptT) +import Data.Bifunctor (Bifunctor (first)) import Data.ByteString qualified as BS import Data.Macaw.Utils.IncComp ( IncCompM, @@ -22,12 +23,7 @@ import System.IO (hPrint, hPutStrLn, stderr) import System.IO.Error (ioeGetErrorType, isDoesNotExistError) handleEitherWithExit :: Show e => Either e a -> IO a -handleEitherWithExit r = do - case r of - Left e -> do - hPrint stderr e - exitFailure - Right b -> pure b +handleEitherWithExit = handleEitherStringWithExit . first show handleEitherStringWithExit :: Either String a -> IO a handleEitherStringWithExit r = do