| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Haxl.Core.DataCache
Description
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 (HashTable TypeRep (SubCache res))
- data SubCache res = forall req a.(Hashable (req a), Eq (req a)) => SubCache (req a -> String) (a -> String) !(HashTable (req a) (res a))
- emptyDataCache :: IO (DataCache res)
- filter :: forall res. (forall a. res a -> IO Bool) -> DataCache res -> IO (DataCache res)
- insert :: (Hashable (req a), Typeable (req a), Eq (req a), Show (req a), Show a) => req a -> res a -> DataCache res -> IO ()
- insertNotShowable :: (Hashable (req a), Typeable (req a), Eq (req a)) => req a -> res a -> DataCache res -> IO ()
- insertWithShow :: (Hashable (req a), Typeable (req a), Eq (req a)) => (req a -> String) -> (a -> String) -> req a -> res a -> DataCache res -> IO ()
- lookup :: Typeable (req a) => req a -> DataCache res -> IO (Maybe (res a))
- showCache :: forall res. DataCache res -> (forall a. res a -> IO (Maybe (Either SomeException a))) -> IO [(TypeRep, [(String, Either SomeException String)])]
- readCache :: forall res ret. DataCache res -> (forall a. res a -> IO ret) -> IO [(TypeRep, [Either SomeException ret])]
Documentation
Arguments
| :: (Hashable (req a), Typeable (req a), Eq (req a), Show (req a), Show a) | |
| => req a | Request |
| -> res a | Result |
| -> DataCache res | |
| -> IO () |
Inserts a request-result pair into the DataCache.
Arguments
| :: (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 | |
| -> IO () |
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 Strings 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.