add instance of MonadFailure to CryptoFailable
This commit is contained in:
parent
ba39c9c18d
commit
393d5804b7
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user