diff --git a/Crypto/Error/Types.hs b/Crypto/Error/Types.hs index e2831bf..4b8a977 100644 --- a/Crypto/Error/Types.hs +++ b/Crypto/Error/Types.hs @@ -8,6 +8,7 @@ -- Cryptographic Error enumeration and handling -- {-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE TypeFamilies #-} module Crypto.Error.Types ( CryptoError(..) , CryptoFailable(..) @@ -21,6 +22,7 @@ module Crypto.Error.Types import qualified Control.Exception as E import Data.Data +import Foundation.Monad (MonadFailure(..)) import Crypto.Internal.Imports -- | Enumeration of all possible errors that can be found in this library @@ -87,6 +89,10 @@ instance Monad CryptoFailable where CryptoPassed a -> m2 a CryptoFailed e -> CryptoFailed e +instance MonadFailure CryptoFailable where + type Failure CryptoFailable = CryptoError + mFail = CryptoFailed + -- | Throw an CryptoError as exception on CryptoFailed result, -- otherwise return the computed value throwCryptoErrorIO :: CryptoFailable a -> IO a