Skip to content

Commit

Permalink
removes mtl
Browse files Browse the repository at this point in the history
  • Loading branch information
ProofOfKeags committed Sep 7, 2022
1 parent 9591b1d commit da81e9a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
2 changes: 0 additions & 2 deletions bitcoin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ library
, hashable >=1.3.0.0
, hspec >=2.7.1
, memory >=0.15.0
, mtl >=2.2.2
, murmur3 >=1.0.3
, network >=3.1.1.1
, safe >=0.3.18
Expand Down Expand Up @@ -164,7 +163,6 @@ test-suite spec
, lens >=4.18.1
, lens-aeson >=1.1
, memory >=0.15.0
, mtl >=2.2.2
, murmur3 >=1.0.3
, network >=3.1.1.1
, safe >=0.3.18
Expand Down
1 change: 0 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dependencies:
- hashable >= 1.3.0.0
- hspec >= 2.7.1
- memory >= 0.15.0
- mtl >= 2.2.2
- murmur3 >= 1.0.3
- network >= 3.1.1.1
- QuickCheck >= 2.13.2
Expand Down
18 changes: 9 additions & 9 deletions src/Haskoin/Block/Headers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ module Haskoin.Block.Headers (
import Control.Applicative ((<|>))
import Control.DeepSeq
import Control.Monad (guard, mzero, unless, when)
import Control.Monad.Except (
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Except (
ExceptT (..),
runExceptT,
throwError,
throwE,
)
import Control.Monad.State.Strict as State (
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.State.Strict as State (
StateT,
get,
gets,
lift,
modify,
)
import Control.Monad.Trans.Maybe
import Data.Binary (Binary (..))
import Data.Bits (shiftL, shiftR, (.&.))
import qualified Data.ByteString as B
Expand Down Expand Up @@ -332,7 +332,7 @@ connectBlocks _ _ [] = return $ Right []
connectBlocks net t bhs@(bh : _) =
runExceptT $ do
unless (chained bhs) $
throwError "Blocks to connect do not form a chain"
throwE "Blocks to connect do not form a chain"
par <-
maybeToExceptT
"Could not get parent block"
Expand All @@ -356,13 +356,13 @@ connectBlocks net t bhs@(bh : _) =
case skM of
Just sk -> return sk
Nothing ->
throwError $
throwE $
"BUG: Could not get skip for block "
++ show (headerHash $ nodeHeader par)
| otherwise = do
let sn = ls !! fromIntegral (nodeHeight par - sh)
when (nodeHeight sn /= sh) $
throwError "BUG: Node height not right in skip"
throwE "BUG: Node height not right in skip"
return sn
where
sh = skipHeight (nodeHeight par + 1)
Expand Down Expand Up @@ -403,7 +403,7 @@ connectBlock net t bh =
case skM of
Just sk -> return sk
Nothing ->
throwError $
throwE $
"BUG: Could not get skip for block "
++ show (headerHash $ nodeHeader par)
bb <- lift getBestBlockHeader
Expand Down
2 changes: 1 addition & 1 deletion src/Haskoin/Transaction/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module Haskoin.Transaction.Builder (
import Control.Applicative ((<|>))
import Control.Arrow (first)
import Control.Monad (foldM, unless)
import Control.Monad.Identity (runIdentity)
import Control.Monad.Trans.Identity (runIdentityT)
import Crypto.Secp256k1
import qualified Data.ByteString as B
import Data.Bytes.Get
Expand Down
5 changes: 2 additions & 3 deletions src/Haskoin/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module Haskoin.Util (
-- * Maybe & Either Helpers
eitherToMaybe,
maybeToEither,
liftEither,
liftMaybe,

-- * Other Helpers
Expand Down Expand Up @@ -58,7 +57,7 @@ module Haskoin.Util (
) where

import Control.Monad
import Control.Monad.Except (ExceptT (..), liftEither)
import Control.Monad.Trans.Except (ExceptT (..))
import Data.Bits
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
Expand Down Expand Up @@ -154,7 +153,7 @@ maybeToEither err = maybe (Left err) Right

-- | Lift a 'Maybe' computation into the 'ExceptT' monad.
liftMaybe :: Monad m => b -> Maybe a -> ExceptT b m a
liftMaybe err = liftEither . maybeToEither err
liftMaybe err = ExceptT . pure . maybeToEither err


-- Various helpers
Expand Down

0 comments on commit da81e9a

Please sign in to comment.