packages feed

stringtable-atom 0.0.3 → 0.0.4

raw patch · 3 files changed

+13/−8 lines, 3 files

Files

src/StringTable/Atom.hsc view
@@ -30,9 +30,10 @@ import Data.Monoid import Data.Dynamic import Data.Bits+import Data.Generics (Data)  newtype Atom = Atom (#type atom_t)-    deriving(Typeable,Eq,Ord)+    deriving(Typeable,Eq,Ord,Data)  class FromAtom a where     fromAtom :: Atom -> a
src/StringTable/AtomMap.hs view
@@ -119,7 +119,8 @@             , showTreeWith             ) where -import Prelude hiding (lookup, filter)+import Prelude hiding (lookup, filter, map)+import qualified Prelude (lookup, filter, map) import StringTable.Atom import qualified Data.IntMap as IM import qualified StringTable.AtomSet as AtomSet@@ -143,6 +144,9 @@ toList :: AtomMap a -> [(Atom, a)] toList lm = [ (unsafeIntToAtom l, x) | (l, x) <- IM.toList $ fromAtomMap lm ] +map :: (a -> b) -> AtomMap a -> AtomMap b+map f = MkAtomMap . IM.map f . fromAtomMap+ mapWithKey :: (Atom -> a -> b) -> AtomMap a -> AtomMap b mapWithKey f lm = MkAtomMap $ IM.mapWithKey (f . unsafeIntToAtom) (fromAtomMap lm) @@ -211,7 +215,7 @@ adjustWithKey ::  (Key -> a -> a) -> Key -> AtomMap a -> AtomMap a adjustWithKey x y z = MkAtomMap (IM.adjustWithKey ((. unsafeIntToAtom) x) (fromAtom y) (fromAtomMap z)) assocs :: AtomMap a -> [(Key,a)]-assocs x = map (\(k, v) -> (unsafeIntToAtom k, v)) (IM.assocs (fromAtomMap x))+assocs x = Prelude.map (\(k, v) -> (unsafeIntToAtom k, v)) (IM.assocs (fromAtomMap x)) difference :: AtomMap a -> AtomMap b -> AtomMap a difference x y = MkAtomMap (IM.difference (fromAtomMap x) (fromAtomMap y)) differenceWith :: (a -> b -> Maybe a) -> AtomMap a -> AtomMap b -> AtomMap a@@ -229,11 +233,11 @@ foldWithKey :: (Key -> a -> b -> b) -> b -> AtomMap a -> b foldWithKey x y z =  (IM.foldWithKey ((. unsafeIntToAtom) x) ( y) (fromAtomMap z)) fromAscListWith :: (a -> a -> a) -> [(Key,a)] -> AtomMap a-fromAscListWith x y = MkAtomMap (IM.fromAscListWith ( x) (map (\(k, v) -> (fromAtom k, v)) y))+fromAscListWith x y = MkAtomMap (IM.fromAscListWith ( x) (Prelude.map (\(k, v) -> (fromAtom k, v)) y)) fromAscListWithKey :: (Key -> a -> a -> a) -> [(Key,a)] -> AtomMap a-fromAscListWithKey x y = MkAtomMap (IM.fromAscListWithKey ((. unsafeIntToAtom) x) (map (\(k, v) -> (fromAtom k, v)) y))+fromAscListWithKey x y = MkAtomMap (IM.fromAscListWithKey ((. unsafeIntToAtom) x) (Prelude.map (\(k, v) -> (fromAtom k, v)) y)) fromListWithKey :: (Key -> a -> a -> a) -> [(Key,a)] -> AtomMap a-fromListWithKey x y = MkAtomMap (IM.fromListWithKey ((. unsafeIntToAtom) x) (map (\(k, v) -> (fromAtom k, v)) y))+fromListWithKey x y = MkAtomMap (IM.fromListWithKey ((. unsafeIntToAtom) x) (Prelude.map (\(k, v) -> (fromAtom k, v)) y)) insertLookupWithKey :: (Key -> a -> a -> a) -> Key -> a -> AtomMap a -> (Maybe a, AtomMap a) insertLookupWithKey x y z w = (\(x, y) -> (x, MkAtomMap y)) (IM.insertLookupWithKey ((. unsafeIntToAtom) x) (fromAtom y) ( z) (fromAtomMap w)) insertWithKey :: (Key -> a -> a -> a) -> Key -> a -> AtomMap a -> AtomMap a@@ -281,7 +285,7 @@ splitLookup :: Key -> AtomMap a -> (AtomMap a,Maybe a,AtomMap a) splitLookup x y = (\(x, y, z) -> (MkAtomMap x, y, MkAtomMap z)) (IM.splitLookup (fromAtom x) (fromAtomMap y)) toAscList :: AtomMap a -> [(Key,a)]-toAscList x = map (\(k, v) -> (unsafeIntToAtom k, v)) (IM.toAscList (fromAtomMap x))+toAscList x = Prelude.map (\(k, v) -> (unsafeIntToAtom k, v)) (IM.toAscList (fromAtomMap x)) unionWithKey :: (Key -> a -> a -> a) -> AtomMap a -> AtomMap a -> AtomMap a unionWithKey x y z = MkAtomMap (IM.unionWithKey ((. unsafeIntToAtom) x) (fromAtomMap y) (fromAtomMap z)) update ::  (a -> Maybe a) -> Key -> AtomMap a -> AtomMap a
stringtable-atom.cabal view
@@ -1,5 +1,5 @@ Name:                stringtable-atom-Version:             0.0.3+Version:             0.0.4 Category:            Data, Pugs Synopsis:            Memoize Strings as Atoms for fast comparison and sorting, with maps and sets Description:         Memoize Strings as Atoms for fast comparison and sorting, with maps and sets