renderable 0.2.0.0 → 0.2.0.1
raw patch · 2 files changed
+16/−12 lines, 2 filesdep ~basedep ~containersdep ~hashable
Dependency ranges changed: base, containers, hashable, transformers
Files
- renderable.cabal +5/−5
- src/Data/Renderable.hs +11/−7
renderable.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.2.0.0+version: 0.2.0.1 -- A short (one-line) description of the package. synopsis: An API for managing renderable resources.@@ -72,10 +72,10 @@ other-extensions: -- Other library packages from which modules are imported.- build-depends: base >=4.8 && <4.9,- containers >= 0.5 && < 0.6,- hashable >= 1.2 && < 1.3,- transformers >= 0.4 && < 0.5+ build-depends: base >=4.6 && <5.0+ , containers >= 0.5+ , hashable >= 1.2+ , transformers >= 0.3 -- Directories containing source files. hs-source-dirs: src
src/Data/Renderable.hs view
@@ -13,10 +13,14 @@ ) where import Prelude hiding (lookup)+import Control.Applicative import Control.Monad import Control.Monad.IO.Class+import Data.Monoid import Data.Hashable+import qualified Data.Traversable as T import Data.IntMap (IntMap)+import Data.Foldable (foldl') import qualified Data.IntMap as IM -------------------------------------------------------------------------------- -- A strategy for rendering@@ -132,17 +136,17 @@ -- return a new cache that can be used to render the next list of -- primitives, along with some info about the comparison of the given and -- returned cache.-renderPrimsWithStats :: (Monad m, Monoid t, Hashable a)+renderPrimsWithStats :: (Functor m, Monad m, Monoid t, Hashable a) => RenderStrategy m t r a -> r -> Cache m t -> [(t, a)] -> m (Cache m t, CacheStats a) renderPrimsWithStats s rez cache prims = do- let (found, missing) = foldl (findRenderer cache)- (mempty, mempty)- (map snd prims)+ let (found, missing) = foldl' (findRenderer cache)+ (mempty, mempty)+ (map snd prims) stale = cache `IM.difference` found -- Clean the stale renderers- sequence_ $ fmap clean stale+ void $ T.sequence $ fmap clean stale -- Get the missing renderers new <- foldM (getRenderer s rez) mempty $ IM.elems missing@@ -162,7 +166,7 @@ -- | Render a list of primitives using renderings stored in the given cache, -- return a new cache that can be used to render the next list of -- primitives. Optionally print some debug info.-renderPrimsDebug :: (MonadIO m, Monoid t, Hashable a)+renderPrimsDebug :: (Functor m, MonadIO m, Monoid t, Hashable a) => Bool -> RenderStrategy m t r a -> r -> Cache m t -> [(t, a)] -> m (Cache m t) renderPrimsDebug debug s rez cache prims = do@@ -173,7 +177,7 @@ -- | Render a list of primitives using renderings stored in the given cache, -- return a new cache that can be used to render the next list of -- primitives.-renderPrims :: (Monad m, Monoid t, Hashable a)+renderPrims :: (Functor m, Monad m, Monoid t, Hashable a) => RenderStrategy m t r a -> r -> Cache m t -> [(t, a)] -> m (Cache m t) renderPrims s rez cache prims = fst <$> renderPrimsWithStats s rez cache prims