diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-04-12 11:43:12 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-04-12 11:43:12 +0200 |
commit | edcd3151ee54f3f71d2ffe0a60348f6641909ce7 (patch) | |
tree | 6d8c56a45d4e2c9f736ee62d727c1d2721984421 /src/Hakyll/Core/Resource/Provider.hs | |
parent | b37da38d3911bbc8381a39fe526e69599d9ddcf1 (diff) | |
download | hakyll-edcd3151ee54f3f71d2ffe0a60348f6641909ce7.tar.gz |
Refactor resource provider creation
Diffstat (limited to 'src/Hakyll/Core/Resource/Provider.hs')
-rw-r--r-- | src/Hakyll/Core/Resource/Provider.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Hakyll/Core/Resource/Provider.hs b/src/Hakyll/Core/Resource/Provider.hs index cb70cf9..d7f08e0 100644 --- a/src/Hakyll/Core/Resource/Provider.hs +++ b/src/Hakyll/Core/Resource/Provider.hs @@ -12,12 +12,14 @@ -- module Hakyll.Core.Resource.Provider ( ResourceProvider (..) + , makeResourceProvider , resourceExists , resourceDigest , resourceModified ) where -import Control.Concurrent (MVar, readMVar, modifyMVar_) +import Control.Applicative ((<$>)) +import Control.Concurrent (MVar, readMVar, modifyMVar_, newMVar) import Control.Monad ((<=<)) import Data.Word (Word8) import Data.Map (Map) @@ -43,6 +45,14 @@ data ResourceProvider = ResourceProvider resourceModifiedCache :: MVar (Map Resource Bool) } +-- | Create a resource provider +-- +makeResourceProvider :: [Resource] -- ^ Resource list + -> (Resource -> IO String) -- ^ String reader + -> (Resource -> IO LB.ByteString) -- ^ ByteString reader + -> IO ResourceProvider -- ^ Resulting provider +makeResourceProvider l s b = ResourceProvider l s b <$> newMVar M.empty + -- | Check if a given identifier has a resource -- resourceExists :: ResourceProvider -> Resource -> Bool |