From a11f20be0fadf21cc96164b49305b59ac7445aa2 Mon Sep 17 00:00:00 2001 From: Julien Tanguy Date: Mon, 17 Aug 2015 18:56:12 +0200 Subject: ghc<7.10.1 compat --- src/Crypto/Macaroon/Verifier.hs | 6 ++++-- src/Crypto/Macaroon/Verifier/Internal.hs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Crypto') diff --git a/src/Crypto/Macaroon/Verifier.hs b/src/Crypto/Macaroon/Verifier.hs index a739437..4fc6aff 100644 --- a/src/Crypto/Macaroon/Verifier.hs +++ b/src/Crypto/Macaroon/Verifier.hs @@ -23,11 +23,13 @@ module Crypto.Macaroon.Verifier ( ) where -import Control.Monad +import Control.Applicative +import Control.Monad hiding (forM) import Control.Monad.IO.Class import Data.Attoparsec.ByteString import Data.Attoparsec.ByteString.Char8 import Data.Bool +import Data.Traversable import qualified Data.ByteString as BS import Data.Either.Combinators @@ -68,7 +70,7 @@ import Crypto.Macaroon.Verifier.Internal -- caveat, parsed it and invalidated it; -- * 'Just' ('Right' '()') if the verifier has successfully verified the -- given caveat -verify :: MonadIO m => Secret -> [Caveat -> m (Maybe (Either ValidationError ()))] -> Macaroon -> m (Either ValidationError Macaroon) +verify :: (Functor m, MonadIO m) => Secret -> [Caveat -> m (Maybe (Either ValidationError ()))] -> Macaroon -> m (Either ValidationError Macaroon) verify secret verifiers m = join <$> forM (verifySig secret m) (verifyCavs verifiers) diff --git a/src/Crypto/Macaroon/Verifier/Internal.hs b/src/Crypto/Macaroon/Verifier/Internal.hs index 73eb66a..5126b2e 100644 --- a/src/Crypto/Macaroon/Verifier/Internal.hs +++ b/src/Crypto/Macaroon/Verifier/Internal.hs @@ -58,7 +58,7 @@ verifySig k m = bool (Left SigMismatch) (Right m) $ derivedKey = toBytes (hmac "macaroons-key-generator" k :: HMAC SHA256) -- | Given a list of verifiers, verify each caveat of the given macaroon -verifyCavs :: MonadIO m +verifyCavs :: (Functor m, MonadIO m) => [Caveat -> m (Maybe (Either ValidationError ()))] -> Macaroon -> m (Either ValidationError Macaroon) -- cgit v1.2.3