packages feed

HMap 1.2.5 → 1.2.6

raw patch · 5 files changed

+41/−39 lines, 5 filesdep +data-defaultPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: data-default

API changes (from Hackage documentation)

+ Data.HMap: instance Default HMap
+ Data.HMap: instance Typeable HMap
- Data.HKeySet: unions :: [HKeySet] -> HKeySet
+ Data.HKeySet: unions :: Foldable f => f HKeySet -> HKeySet

Files

ChangeLog view
@@ -1,3 +1,5 @@+1.2.6: Git pulls from Piotr Młodawski (Typable and Default instances)+ 1.2.5: Fixed building on older GHC  1.2.4: Added constraint (thanks schell!)
Data/HKeyPrivate.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE  ScopedTypeVariables,RankNTypes, GADTs, CPP, EmptyDataDecls #-} +{-# LANGUAGE  ScopedTypeVariables,RankNTypes, GADTs, CPP, EmptyDataDecls #-} ----------------------------------------------------------------------------- -- | -- Module      :  Data.HMap@@ -7,10 +7,10 @@ -- Maintainer  :  atzeus@gmail.org -- Stability   :  provisional -- Portability :  portable--- +-- -- A HKey is a key that can be used in 'HMap','HKeySet' or 'Untypeable' -- it carries the type of thing it points to in its own type.-module Data.HKeyPrivate( +module Data.HKeyPrivate(               HKey(..)             , withKey             , T@@ -42,30 +42,30 @@   Keys --------------------------------------------------------------------} --- | The datatype of Keys. +-- | The datatype of Keys. -----   [x] The scope of this key. This can either be 'T' for top-level keys created with 'createKey' or +--   [x] The scope of this key. This can either be 'T' for top-level keys created with 'createKey' or --       an existential type for keys introduced by 'withKey' (or with the Key monad 'KeyM').--- +-- --   [a] The type of things that can be sorted at this key.--- +-- --  For example, @Key T Int@ is a top-level key that can be used to store values---  of type @Int@ in a heterogenous map.     +--  of type @Int@ in a heterogenous map. newtype HKey s a = Key Unique  -- | /O(1)/. Scopes a key to the given function -- The key cannot escape the function (because of the existential type). -- -- The implementation actually *creates* a key, but because the key cannot escape--- the given function @f@, there is no way to observe that if we run +-- the given function @f@, there is no way to observe that if we run -- @withKey f@ twice, that it will get a different key the second time.  withKey :: (forall x. HKey x a -> b) -> b-withKey f = unsafePerformIO $ liftM f createKey -{-# NOINLINE withKey #-} +withKey f = unsafePerformIO $ liftM f createKey+{-# NOINLINE withKey #-}  -- | The scope of top-level keys.-data T +data T  -- | /O(1)/. Create a new top-level key. createKey :: IO (HKey T a)@@ -96,7 +96,7 @@  instance Applicative (TermM f) where   pure = return-  (<*>) = ap +  (<*>) = ap  type Bind f a v = (forall w. f w -> (w -> TermM f a) -> v) @@ -113,8 +113,8 @@ --   Keys cannot escape the monad, analogous to the ST Monad. --   Can be used instead of the 'withKey' function if you --   need an statically unknown number of keys.--- --- The applicative instance is more non-strict than +--+-- The applicative instance is more non-strict than -- the standard 'ap': -- --  let hang = getKey >> hang@@ -131,11 +131,11 @@   pure = return   f <*> x = do fv <- keyTSplit f; xv <- keyTSplit x; lift (ap fv xv) -instance Monad m =>Monad (KeyT s m) where+instance Monad m => Monad (KeyT s m) where   return   = KeyT . Return   c >>= f  = KeyT $ getKT c >>= getKT . f -instance MonadFix m => MonadFix (KeyT s m) where +instance MonadFix m => MonadFix (KeyT s m) where   mfix m = KeyT $ Bind (Prim (GDFix m)) Return  @@ -155,14 +155,14 @@ --  As an analogy, think of a random number generator --  some random number generator can be split, from one random number generator --  we obtain two distinct random number generator that are unrelated.--- +-- --  The KeyT monad gives us access to a name source, this operation allows---  us to split the name source. The generated name from both this and +--  us to split the name source. The generated name from both this and --  the split off computation have the same scope, but are otherwise underlated.--- +-- --  Notice that the sharing of the same scope is not a problem --  because the monad ensures referential transparency.---   +-- keyTSplit :: KeyT s m a -> KeyT s m (m a) keyTSplit m = KeyT $ Bind (Prim (Split m)) Return @@ -171,20 +171,20 @@  type Key s = KeyT s Identity -runKey :: (forall s. Key s a) -> a +runKey :: (forall s. Key s a) -> a runKey m = runIdentity (runKeyT m)  -- | Run a key monad. Existential type makes sure keys cannot escape. runKeyT :: forall m a. Monad m => (forall s. KeyT s m a) -> m a runKeyT (KeyT m) = loop m where-  loop :: TermM (GD T m) b -> m b	+  loop :: TermM (GD T m) b -> m b   loop = interpret bind return  where   {-# NOINLINE bind #-}   bind :: Bind (GD T m) x (m x)   bind (Lift m) c = m >>= loop . c   bind GetKey  c = unsafePerformIO (liftM (loop . c) createKey)   bind (Split (KeyT m)) c = loop $ c $ loop m-  bind (GDFix f) c = mfix (loop . getKT . f) >>= loop . c +  bind (GDFix f) c = mfix (loop . getKT . f) >>= loop . c   
Data/HKeySet.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE   CPP #-} +{-# LANGUAGE   CPP #-} ----------------------------------------------------------------------------- -- | -- Module      :  Data.HKeySet@@ -8,7 +8,7 @@ -- Stability   :  provisional -- Portability :  portable ----- A set of 'HKey's +-- A set of 'HKey's module Data.HKeySet   (@@ -48,8 +48,8 @@ import qualified Data.List as List import Data.Foldable hiding (empty,null) import Prelude hiding (null)--- | The type of hetrogenous key sets. -newtype HKeySet = HKeySet HMap +-- | The type of hetrogenous key sets.+newtype HKeySet = HKeySet HMap   -- | /O(1)/ Construct an empty key set.@@ -73,8 +73,8 @@ {-# INLINE union #-}  -- | Construct a key set containing all elements from a list of key sets.-unions :: [HKeySet] -> HKeySet-unions = List.foldl' union empty+unions :: Foldable f => f HKeySet -> HKeySet+unions = foldl' union empty {-# INLINE unions #-}  -- | /O(1)/ Return 'True' if this  key set is empty, 'False' otherwise.@@ -96,7 +96,7 @@ #endif  -- | /O(min(n,W))/ Add the specified value to this set.-insert :: HKey x a -> HKeySet  -> HKeySet +insert :: HKey x a -> HKeySet  -> HKeySet insert x (HKeySet s) = HKeySet (S.insert x undefined s) #if __GLASGOW_HASKELL__ >= 700 {-# INLINABLE insert #-}
Data/HMap.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE  RankNTypes, GADTs, CPP, EmptyDataDecls #-} +{-# LANGUAGE DeriveDataTypeable, RankNTypes, GADTs, CPP, EmptyDataDecls #-} ----------------------------------------------------------------------------- -- | -- Module      :  Data.HMap@@ -173,6 +173,7 @@ where import qualified Data.HKey  import Prelude hiding (lookup,null)+import Data.Default import Data.Untypeable import Data.Unique import Data.HKeyPrivate@@ -180,14 +181,13 @@ import Control.Monad import Data.Hashable import Data.HashMap.Lazy(HashMap)-+import Data.Typeable(Typeable)  import qualified Data.HashMap.Lazy as M import Data.Maybe(fromJust,isJust) import System.Mem.Weak import System.IO.Unsafe - {--------------------------------------------------------------------   HMap --------------------------------------------------------------------}@@ -195,9 +195,9 @@   -- | The type of hetrogenous maps. -newtype HMap = HMap (HashMap Unique (Weak HideType)) -+newtype HMap = HMap (HashMap Unique (Weak HideType)) deriving Typeable +instance Default HMap where def = empty   {--------------------------------------------------------------------
HMap.cabal view
@@ -1,6 +1,6 @@ Name:                HMap-Version:             1.2.5-Synopsis:	     Fast heterogeneous maps and unconstrained typeable like functionality.+Version:             1.2.6+Synopsis:            Fast heterogeneous maps and unconstrained typeable like functionality. Description:         Fast heterogeneous maps based on Hashmaps and type-able like functionality for type that are not typeable. License:             BSD3 License-file:        LICENSE@@ -13,7 +13,7 @@ Category:            Data, Data Structures Tested-With:         GHC==7.6.3 Library-  Build-Depends: base >= 2 && <= 6, unordered-containers >= 0.2, hashable >= 1.2, mtl >= 1.0+  Build-Depends: base >= 2 && <= 6, data-default, unordered-containers >= 0.2, hashable >= 1.2, mtl >= 1.0   Exposed-modules: Data.HMap, Data.HKey, Data.Untypeable, Data.HKeySet   other-modules:       Data.HKeyPrivate, Data.HideType   Extensions:	 RankNTypes, GADTs, CPP, EmptyDataDecls