Skip to content

Commit

Permalink
backport tryError
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 17, 2024
1 parent 1cd50c3 commit 8a68c08
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cabal.GHC-9.4.8.config
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ constraints: any.BoundedChan ==1.0.3.0,
mod +semirings +vector,
any.monad-control ==1.0.3.1,
any.monadLib ==3.10.1,
any.mtl ==2.3.1,
any.mtl ==2.2.2,
any.mwc-random ==0.15.0.2,
any.network ==3.1.4.0,
network -devel,
Expand Down
2 changes: 1 addition & 1 deletion cabal.GHC-9.6.5.config
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ constraints: any.BoundedChan ==1.0.3.0,
mod +semirings +vector,
any.monad-control ==1.0.3.1,
any.monadLib ==3.10.1,
any.mtl ==2.3.1,
any.mtl ==2.2.1,
any.mwc-random ==0.15.0.2,
any.network ==3.1.4.0,
network -devel,
Expand Down
2 changes: 1 addition & 1 deletion cabal.GHC-9.8.2.config
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ constraints: any.BoundedChan ==1.0.3.0,
mod +semirings +vector,
any.monad-control ==1.0.3.1,
any.monadLib ==3.10.1,
any.mtl ==2.3.1,
any.mtl ==2.2.1,
any.mwc-random ==0.15.0.2,
any.network ==3.1.4.0,
network -devel,
Expand Down
2 changes: 1 addition & 1 deletion cryptol.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ library
toml-parser >= 2.0 && <2.1,
transformers-base >= 0.4,
vector,
mtl >= 2.3.1,
mtl >= 2.2.1,
time >= 1.6.0.1,
panic >= 0.3,
what4 >= 1.4 && < 1.7
Expand Down
6 changes: 5 additions & 1 deletion src/Cryptol/Project/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Control.Monad.Reader
import Control.Monad.State
import Control.Monad.Except
import Control.Monad.Except hiding (tryError)

Check warning on line 29 in src/Cryptol/Project/Monad.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 9.4.8, 3.10.3.0, true)

Module ‘Control.Monad.Except’ does not export ‘tryError’

Check warning on line 29 in src/Cryptol/Project/Monad.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, 9.4.8, false)

Module ‘Control.Monad.Except’ does not export ‘tryError’

Check warning on line 29 in src/Cryptol/Project/Monad.hs

View workflow job for this annotation

GitHub Actions / build (windows-2019, 9.4.8, true)

Module ‘Control.Monad.Except’ does not export ‘tryError’

Check warning on line 29 in src/Cryptol/Project/Monad.hs

View workflow job for this annotation

GitHub Actions / build (macos-13, 9.4.8, true)

Module ‘Control.Monad.Except’ does not export ‘tryError’

Check warning on line 29 in src/Cryptol/Project/Monad.hs

View workflow job for this annotation

GitHub Actions / build (macos-14, 9.4.8, true)

Module ‘Control.Monad.Except’ does not export ‘tryError’
import System.Directory
import System.FilePath (makeRelative)

Expand Down Expand Up @@ -112,6 +112,10 @@ doIO m = doModule (M.io m)
tryLoadM :: LoadM Err a -> LoadM any (Either M.ModuleError a)
tryLoadM (LoadM m) = LoadM (tryError m)

-- Introduced in mtl-2.3.1 which we can't rely upon yet
tryError :: MonadError e m => m a -> m (Either e a)
tryError action = (Right <$> action) `catchError` (pure . Left)

-- | Print a line
lPutStrLn :: String -> LoadM any ()
lPutStrLn msg = doModuleNonFail (withLogger logPutStrLn msg)
Expand Down

0 comments on commit 8a68c08

Please sign in to comment.