Skip to content

Commit c257b99

Browse files
authored
Merge pull request #4808 from input-output-hk/newhoggy/switch-to-hoistMaybe
Use hoistMaybe
2 parents ff98f05 + 25302f6 commit c257b99

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

Diff for: cardano-api/src/Cardano/Api/Convenience/Query.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ module Cardano.Api.Convenience.Query (
1515

1616
import Prelude
1717

18-
import Control.Monad.Trans.Except (ExceptT(..), except, runExceptT)
19-
import Control.Monad.Trans.Except.Extra (firstExceptT)
18+
import Control.Monad.Trans.Except (ExceptT (..), except, runExceptT)
19+
import Control.Monad.Trans.Except.Extra (firstExceptT, hoistMaybe)
2020
import Data.Bifunctor (first)
2121
import Data.Function ((&))
2222
import Data.Set (Set)
@@ -78,7 +78,7 @@ queryStateForBalancedTx era networkId allTxIns = runExceptT $ do
7878
qSbe <- except $ getSbe $ cardanoEraStyle era
7979

8080
qeInMode <- toEraInMode era CardanoMode
81-
& onNothingThrow (EraConsensusModeMismatch (AnyConsensusMode CardanoMode) (getIsCardanoEraConstraint era $ AnyCardanoEra era))
81+
& hoistMaybe (EraConsensusModeMismatch (AnyConsensusMode CardanoMode) (getIsCardanoEraConstraint era $ AnyCardanoEra era))
8282

8383
-- Queries
8484
let utxoQuery = QueryInEra qeInMode $ QueryInShelleyBasedEra qSbe

Diff for: cardano-api/src/Cardano/Api/Utils.hs

-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module Cardano.Api.Utils
1616
, failEitherWith
1717
, noInlineMaybeToStrictMaybe
1818
, note
19-
, onNothingThrow
2019
, parseFilePath
2120
, readFileBlocking
2221
, renderEra
@@ -51,7 +50,6 @@ import System.Directory (emptyPermissions, readable, setPermissions)
5150
#endif
5251

5352
import Cardano.Api.Eras
54-
import Control.Monad.Trans.Except (ExceptT, throwE)
5553

5654
(?!) :: Maybe a -> e -> Either e a
5755
Nothing ?! e = Left e
@@ -61,9 +59,6 @@ Just x ?! _ = Right x
6159
Left e ?!. f = Left (f e)
6260
Right x ?!. _ = Right x
6361

64-
onNothingThrow :: Monad m => e -> Maybe a -> ExceptT e m a
65-
onNothingThrow e = maybe (throwE e) pure
66-
6762
{-# NOINLINE noInlineMaybeToStrictMaybe #-}
6863
noInlineMaybeToStrictMaybe :: Maybe a -> StrictMaybe a
6964
noInlineMaybeToStrictMaybe Nothing = SNothing

0 commit comments

Comments
 (0)