on master help sign in
Style nazi strikes!
edfdb7dJasper Van der Jeugt
src/Hakyll/Core/Resource/Provider.hs+4−3
@@ -36,8 +36,8 @@ import Hakyll.Core.Resource
36-- | A value responsible for retrieving and listing resources
36-- | A value responsible for retrieving and listing resources
37--
37--
38data ResourceProvider = ResourceProvider
38data ResourceProvider = ResourceProvider
39− { -- | A list of all resources this provider is able to provide
39+ { -- | A set of all resources this provider is able to provide
40− resourceSet :: S.Set Resource
40+ resourceSet :: S.Set Resource
41 , -- | Retrieve a certain resource as string
41 , -- | Retrieve a certain resource as string
42 resourceString :: Resource -> IO String
42 resourceString :: Resource -> IO String
43 , -- | Retrieve a certain resource as lazy bytestring
43 , -- | Retrieve a certain resource as lazy bytestring
@@ -55,7 +55,8 @@ makeResourceProvider :: [Resource] -- ^ Resource list
55 -> (Resource -> IO LB.ByteString) -- ^ ByteString reader
55 -> (Resource -> IO LB.ByteString) -- ^ ByteString reader
56 -> (Resource -> IO UTCTime) -- ^ Time checker
56 -> (Resource -> IO UTCTime) -- ^ Time checker
57 -> IO ResourceProvider -- ^ Resulting provider
57 -> IO ResourceProvider -- ^ Resulting provider
58+makeResourceProvider l s b t =
58−makeResourceProvider l s b t = ResourceProvider (S.fromList l) s b t <$> newMVar M.empty
59+ ResourceProvider (S.fromList l) s b t <$> newMVar M.empty
59
60
60-- | Get the list of all resources
61-- | Get the list of all resources
61resourceList :: ResourceProvider -> [Resource]
62resourceList :: ResourceProvider -> [Resource]
src/Hakyll/Core/Store.hs+8−6
@@ -54,7 +54,9 @@ makeStore :: Bool -- ^ Use in-memory caching
54 -> FilePath -- ^ Directory to use for hard disk storage
54 -> FilePath -- ^ Directory to use for hard disk storage
55 -> IO Store -- ^ Store
55 -> IO Store -- ^ Store
56makeStore inMemory directory = do
56makeStore inMemory directory = do
57+ lru <- if inMemory
57− lru <- if inMemory then Just <$> LRU.newAtomicLRU storeLRUSize else return Nothing
58+ then Just <$> LRU.newAtomicLRU storeLRUSize
59+ else return Nothing
58 return Store
60 return Store
59 { storeDirectory = directory
61 { storeDirectory = directory
60 , storeLRU = lru
62 , storeLRU = lru
@@ -63,7 +65,7 @@ makeStore inMemory directory = do
63-- | Auxiliary: add an item to the map
65-- | Auxiliary: add an item to the map
64--
66--
65cacheInsert :: (Binary a, Typeable a) => Store -> FilePath -> a -> IO ()
67cacheInsert :: (Binary a, Typeable a) => Store -> FilePath -> a -> IO ()
66−cacheInsert (Store _ Nothing) _ _ = return ()
68+cacheInsert (Store _ Nothing) _ _ = return ()
67cacheInsert (Store _ (Just lru)) path value =
69cacheInsert (Store _ (Just lru)) path value =
68 LRU.insert path (Storable value) lru
70 LRU.insert path (Storable value) lru
69
71
@@ -75,10 +77,10 @@ cacheLookup (Store _ Nothing) _ = return NotFound
75cacheLookup (Store _ (Just lru)) path = do
77cacheLookup (Store _ (Just lru)) path = do
76 res <- LRU.lookup path lru
78 res <- LRU.lookup path lru
77 case res of
79 case res of
78− Nothing -> return NotFound
80+ Nothing -> return NotFound
79− Just (Storable s) -> return $ case cast s of
81+ Just (Storable s) -> return $ case cast s of
80− Nothing -> WrongType (typeOf s) $ typeOf (undefined :: a)
82+ Nothing -> WrongType (typeOf s) $ typeOf (undefined :: a)
81− Just s' -> Found s'
83+ Just s' -> Found s'
82
84
83-- | Create a path
85-- | Create a path
84--
86--