From bc92f7fea561a3f9ae69fd499e817f9244fcb206 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 26 Dec 2010 16:22:05 +0100 Subject: Add resourceDigest function --- src/Hakyll/Core/ResourceProvider.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Hakyll/Core/ResourceProvider.hs b/src/Hakyll/Core/ResourceProvider.hs index 94dda5b..ba249ca 100644 --- a/src/Hakyll/Core/ResourceProvider.hs +++ b/src/Hakyll/Core/ResourceProvider.hs @@ -4,11 +4,17 @@ -- module Hakyll.Core.ResourceProvider ( ResourceProvider (..) + , resourceDigest ) where -import Hakyll.Core.Identifier +import Control.Monad ((<=<)) +import Data.Word (Word8) import qualified Data.ByteString.Lazy as LB +import OpenSSL.Digest.ByteString.Lazy (digest) +import OpenSSL.Digest (MessageDigest (MD5)) + +import Hakyll.Core.Identifier -- | A value responsible for retrieving and listing resources -- @@ -20,3 +26,8 @@ data ResourceProvider = ResourceProvider , -- | Retrieve a certain resource as lazy bytestring resourceLazyByteString :: Identifier -> IO LB.ByteString } + +-- | Retrieve a digest for a given resource +-- +resourceDigest :: ResourceProvider -> Identifier -> IO [Word8] +resourceDigest provider = digest MD5 <=< resourceLazyByteString provider -- cgit v1.2.3