From a11f20be0fadf21cc96164b49305b59ac7445aa2 Mon Sep 17 00:00:00 2001 From: Julien Tanguy Date: Mon, 17 Aug 2015 18:56:12 +0200 Subject: [PATCH] ghc<7.10.1 compat --- default.nix | 5 +++-- hmacaroons.cabal | 6 +++--- src/Crypto/Macaroon/Verifier.hs | 6 ++++-- src/Crypto/Macaroon/Verifier/Internal.hs | 2 +- test/Crypto/Macaroon/Instances.hs | 1 + 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/default.nix b/default.nix index b1404ef..a392583 100644 --- a/default.nix +++ b/default.nix @@ -4,7 +4,7 @@ }: mkDerivation { pname = "hmacaroons"; - version = "0.2.0.0"; + version = "0.4.0.0"; src = ./.; buildDepends = [ attoparsec base base64-bytestring byteable bytestring cereal @@ -12,7 +12,8 @@ mkDerivation { ]; testDepends = [ attoparsec base base64-bytestring byteable bytestring cereal - cryptohash either hex QuickCheck tasty tasty-hunit tasty-quickcheck + cryptohash deepseq either hex QuickCheck tasty tasty-hunit + tasty-quickcheck transformers ]; homepage = "https://github.com/jtanguy/hmacaroons"; description = "Haskell implementation of macaroons"; diff --git a/hmacaroons.cabal b/hmacaroons.cabal index 83b2cd7..85958b9 100644 --- a/hmacaroons.cabal +++ b/hmacaroons.cabal @@ -1,5 +1,5 @@ name: hmacaroons -version: 0.3.0.0 +version: 0.4.0.0 synopsis: Haskell implementation of macaroons description: Hmacaroons is a pure haskell implementation of macaroons. It aims to @@ -58,7 +58,7 @@ library Crypto.Macaroon.Verifier.Internal build-depends: base >=4 && < 5, attoparsec >=0.12, - transformers >= 0.4, + transformers >= 0.3, bytestring >=0.10, base64-bytestring >= 1.0, byteable >= 0.1 && <0.2, @@ -110,4 +110,4 @@ test-suite test tasty-quickcheck >= 0.8, QuickCheck >= 2.8, deepseq >= 1.1, - transformers >= 0.4 + transformers >= 0.3 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) diff --git a/test/Crypto/Macaroon/Instances.hs b/test/Crypto/Macaroon/Instances.hs index 6348c56..019c094 100644 --- a/test/Crypto/Macaroon/Instances.hs +++ b/test/Crypto/Macaroon/Instances.hs @@ -11,6 +11,7 @@ This test suite is based on the pymacaroons test suite: -} module Crypto.Macaroon.Instances where +import Control.Applicative import Control.Monad import Data.Byteable import qualified Data.ByteString as BS -- 2.41.0