Safe Haskell | None |
---|---|
Language | Haskell2010 |
A cache mapping data requests to their results. This module is provided for access to Haxl internals only; most users should not need to import it.
Synopsis
- newtype DataCache res = DataCache (HashMap TypeRep (SubCache res))
- data SubCache res = (Hashable (req a), Eq (req a), Typeable (req a)) => SubCache (req a -> String) (a -> String) !(HashMap (req a) (res a))
- emptyDataCache :: DataCache res
- insert :: (Hashable (req a), Typeable (req a), Eq (req a), Show (req a), Show a) => req a -> res a -> DataCache res -> DataCache res
- insertNotShowable :: (Hashable (req a), Typeable (req a), Eq (req a)) => req a -> res a -> DataCache res -> DataCache res
- insertWithShow :: (Hashable (req a), Typeable (req a), Eq (req a)) => (req a -> String) -> (a -> String) -> req a -> res a -> DataCache res -> DataCache res
- lookup :: Typeable (req a) => req a -> DataCache res -> Maybe (res a)
- showCache :: forall res. DataCache res -> (forall a. res a -> IO (Maybe (Either SomeException a))) -> IO [(TypeRep, [(String, Either SomeException String)])]
Documentation
emptyDataCache :: DataCache res Source #
A new, empty DataCache
.
:: (Hashable (req a), Typeable (req a), Eq (req a), Show (req a), Show a) | |
=> req a | Request |
-> res a | Result |
-> DataCache res | |
-> DataCache res |
Inserts a request-result pair into the DataCache
.
:: (Hashable (req a), Typeable (req a), Eq (req a)) | |
=> (req a -> String) | Show function for request |
-> (a -> String) | Show function for result |
-> req a | Request |
-> res a | Result |
-> DataCache res | |
-> DataCache res |
Inserts a request-result pair into the DataCache
, with the given
functions used to show the request and result.
Looks up the cached result of a request.
showCache :: forall res. DataCache res -> (forall a. res a -> IO (Maybe (Either SomeException a))) -> IO [(TypeRep, [(String, Either SomeException String)])] Source #
Dumps the contents of the cache, with requests and responses
converted to String
s using the supplied show functions. The
entries are grouped by TypeRep
. Note that this will fail if
insertNotShowable
has been used to insert any entries.