-- | A very inefficient example implementation.
--
-- >>> withAssocCache testC
-- one
-- two
-- testing
-- [3,3,3,3,7,7]
assocCache :: (Monad m, Eq k) => Cache (StateT [(k,a)] m) k a
assocCache = Cache
    { readCache      = \k   -> liftM (lookup k) $ get
    , writeCache     = \k v -> modify ((k,v):)
                            >> return True  -- never full.
    , clearCache     =         put []
    , clearFromCache = \k   -> modify $ filter $ (/= k) . fst
    }
assocCache :: (Monad m, Eq k) => Cache (StateT [(k,a)] m) k a
assocCache = Cache
    { readCache      = \k   -> liftM (lookup k) $ get
    , writeCache     = \k v -> modify ((k,v):)
                            >> return True  -- never full.
    , clearCache     =         put []
    , clearFromCache = \k   -> modify $ filter $ (/= k) . fst
    }
assocCache = Cache
    { readCache      = \k   -> liftM (lookup k) $ get
    , writeCache     = \k v -> modify ((k,v):)
                            >> return True  -- never full.
    , clearCache     =         put []
    , clearFromCache = \k   -> modify $ filter $ (/= k) . fst
    }