diff --git a/bindings/haskell/keystone.cabal b/bindings/haskell/keystone.cabal index e8b16037..9fd4716d 100644 --- a/bindings/haskell/keystone.cabal +++ b/bindings/haskell/keystone.cabal @@ -27,8 +27,7 @@ library other-modules: Keystone.Internal.Util build-depends: base >= 4 && < 5 , bytestring >= 0.9.1 - , transformers < 0.6 - , either >= 4.4 + , transformers >= 0.4 && < 0.6 hs-source-dirs: src c-sources: src/cbits/keystone_wrapper.c include-dirs: src/include diff --git a/bindings/haskell/src/Keystone.hs b/bindings/haskell/src/Keystone.hs index c8e838c2..6c2268ae 100644 --- a/bindings/haskell/src/Keystone.hs +++ b/bindings/haskell/src/Keystone.hs @@ -32,7 +32,7 @@ module Keystone ) where import Control.Monad.Trans.Class (lift) -import Control.Monad.Trans.Either (left, right, runEitherT) +import Control.Monad.Trans.Except (runExceptT, throwE) import Data.ByteString (ByteString, packCStringLen) import Data.List (intercalate) import Foreign @@ -50,7 +50,7 @@ runAssembler :: Assembler a -- ^ The assembler code to execute -> IO (Either Error a) -- ^ A result on success, or an 'Error' on -- failure runAssembler = - runEitherT + runExceptT -- | Create a new instance of the Keystone assembler. open :: Architecture -- ^ CPU architecture @@ -65,7 +65,7 @@ open arch mode = do lift $ mkEngine ksPtr else -- Otherwise return an error - left err + throwE err option :: Engine -- ^ 'Keystone' engine handle -> OptionType -- ^ Type of option to set @@ -74,9 +74,9 @@ option :: Engine -- ^ 'Keystone' engine handle option ks optType optValue = do err <- lift $ ksOption ks optType optValue if err == ErrOk then - right () + return () else - left err + throwE err -- | Assemble a list of statements. assemble :: Engine -- ^ 'Keystone' engine handle @@ -97,11 +97,11 @@ assemble ks stmts addr = do -- statement count bs <- lift $ packCStringLen (castPtr encPtr, encSize) lift $ ksFree encPtr - right (bs, statCount) + return (bs, statCount) else do -- On failure, call errno for error code err <- errno ks - left err + throwE err where maybeZ = maybe 0 id ------------------------------------------------------------------------------- diff --git a/bindings/haskell/src/Keystone/Internal/Core.chs b/bindings/haskell/src/Keystone/Internal/Core.chs index 1a541ab8..c4e5621a 100644 --- a/bindings/haskell/src/Keystone/Internal/Core.chs +++ b/bindings/haskell/src/Keystone/Internal/Core.chs @@ -14,7 +14,7 @@ way cabal handles ordering of chs files. module Keystone.Internal.Core where import Control.Monad -import Control.Monad.Trans.Either (EitherT) +import Control.Monad.Trans.Except (ExceptT) import Foreign {# context lib = "keystone" #} @@ -48,4 +48,4 @@ mkEngine ptr = -- | The assembler runs in the IO monad and allows for the handling of errors -- "under the hood". -type Assembler a = EitherT Error IO a +type Assembler a = ExceptT Error IO a diff --git a/bindings/haskell/src/Keystone/Internal/Util.hs b/bindings/haskell/src/Keystone/Internal/Util.hs index 6a541b72..086e3890 100644 --- a/bindings/haskell/src/Keystone/Internal/Util.hs +++ b/bindings/haskell/src/Keystone/Internal/Util.hs @@ -6,6 +6,7 @@ License : GPL-2 -} module Keystone.Internal.Util where +import Control.Applicative ((<$>)) import Data.Bits -- | Combine a list of Enums by performing a bitwise-OR.