packages feed

xhb-atom-cache 0.1.0.0 → 0.1.0.1

raw patch · 2 files changed

+35/−7 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Graphics.XHB.AtomCache: AtomCacheT :: StateT AtomState m a -> AtomCacheT m a
+ Graphics.XHB.AtomCache: AtomCacheT :: StateT AtomCache m a -> AtomCacheT m a
- Graphics.XHB.AtomCache: unAtomT :: AtomCacheT m a -> StateT AtomState m a
+ Graphics.XHB.AtomCache: unAtomT :: AtomCacheT m a -> StateT AtomCache m a

Files

src/Graphics/XHB/AtomCache.hs view
@@ -64,9 +64,9 @@  type AtomName = String -type AtomState = (HashMap AtomId ATOM, HashMap ATOM AtomId)+type AtomCache = (HashMap AtomId ATOM, HashMap ATOM AtomId) -newtype AtomCacheT m a = AtomCacheT { unAtomT :: StateT AtomState m a }+newtype AtomCacheT m a = AtomCacheT { unAtomT :: StateT AtomCache m a }     deriving (Applicative, Functor, Monad, MonadIO, Typeable)  instance MonadTrans AtomCacheT where@@ -78,10 +78,38 @@ runAtomCacheT :: Monad m => AtomCacheT m a -> m a runAtomCacheT = flip evalStateT (M.empty, M.empty) . unAtomT --- | Preseed the atom cache with `ATOM`s--- Example:--- @ > let atoms = ["_NET_CLIENT_LIST", "_NET_NUMBER_OF_DESKTOPS"] @--- @ > fromJust <$> X.connect >>= \c -> runAtomCacheT . seedAtoms c atoms $ mapM_ (\n -> unsafeLookupAtom n >>= liftIO . print) @+-- | Preseed the atom cache with `AtomLike`s. Example:+--+-- @+-- {-# LANGUAGE DeriveDataTypeable #-}+--+-- import Data.Maybe (fromJust)+-- import Data.Typeable (Typeable)+-- import Data.Hashable (Hashable(..))+-- import Control.Applicative ((\<$\>))+-- import Control.Monad (forM_, void)+-- import Control.Monad.IO.Class (liftIO)+-- import Graphics.XHB (connect)+-- import Graphics.XHB.AtomCache+--+-- data ATOMS = NET_CLIENT_LIST | NET_NUMBER_OF_DESKTOPS+--     deriving (Eq, Show, Typeable)+--+-- instance Hashable ATOMS where+--     hashWithSalt s = hashWithSalt s . show+--+-- instance AtomLike ATOMS where+--     toAtomName a = '_' : show a+--+-- atoms :: [ATOMS]+-- atoms = [NET_CLIENT_LIST, NET_NUMBER_OF_DESKTOPS]+--+-- main :: IO ()+-- main = do+--     c <- fromJust \<$\> connect+--     void $ runAtomCacheT . seedAtoms c atoms $ do+--         forM_ atoms $ \\a -> unsafeLookupATOM a >>= liftIO . print+-- @ seedAtoms :: (AtomLike l, Applicative m, MonadIO m)           => Connection -> [l] -> AtomCacheT m a -> AtomCacheT m (Either SomeError a) seedAtoms _ [] m         = Right <$> m
xhb-atom-cache.cabal view
@@ -1,5 +1,5 @@ name:                xhb-atom-cache-version:             0.1.0.0+version:             0.1.0.1 synopsis:            Atom cache for XHB description:         Atom cache for XHB license:             BSD2