@@ -1,6 +1,6 @@
11-- | A store for stroing and retreiving items
22--
3−{-# LANGUAGE ExistentialQuantification #-}
3+{-# LANGUAGE ExistentialQuantification, ScopedTypeVariables #-}
44module Hakyll.Core.Store
55 ( Store
66 , StoreGet (..)
@@ -17,7 +17,7 @@ import Data.Map (Map)
1717import qualified Data.Map as M
1818
1919import Data.Binary (Binary, encodeFile, decodeFile)
20−import Data.Typeable (Typeable, cast)
20+import Data.Typeable (Typeable, TypeRep, cast, typeOf)
2121
2222import Hakyll.Core.Identifier
2323import Hakyll.Core.Util.File
@@ -30,8 +30,8 @@ data Storable = forall a. (Binary a, Typeable a) => Storable a
3030--
3131data StoreGet a = Found a
3232 | NotFound
33− | WrongType
34− deriving (Show, Eq, Ord)
33+ | WrongType TypeRep TypeRep
34+ deriving (Show, Eq)
3535
3636-- | Data structure used for the store
3737--
@@ -79,7 +79,7 @@ storeSet store name identifier value = do
7979
8080-- | Load an item
8181--
82−storeGet :: (Binary a, Typeable a)
82+storeGet :: forall a. (Binary a, Typeable a)
8383 => Store -> String -> Identifier -> IO (StoreGet a)
8484storeGet store name identifier = do
8585 -- First check the in-memory map
@@ -87,7 +87,7 @@ storeGet store name identifier = do
8787 case M.lookup path map' of
8888 -- Found in the in-memory map
8989 Just (Storable s) -> return $ case cast s of
90− Nothing -> WrongType
90+ Nothing -> WrongType (typeOf s) $ typeOf (undefined :: a)
9191 Just s' -> Found s'
9292 -- Not found in the map, try the filesystem
9393 Nothing -> do