packages feed

stringtable-atom 0.0.4 → 0.0.5

raw patch · 4 files changed

+24/−12 lines, 4 filesdep ~base

Dependency ranges changed: base

Files

cbits/StringTable_cbits.c view
@@ -157,7 +157,7 @@                 if(ATOM_VALID(a)) {                         fprintf(file,"%u:",ATOM_LEN(a));                         print_quoted(file, ATOM_PTR(a),ATOM_LEN(a));-                        fwrite("\n",1,1,file);+                        if (fwrite("\n",1,1,file)) return;                 }         } }@@ -168,8 +168,8 @@                 atom_t a = htable[i].atom;                 if(ATOM_VALID(a)) {                         printf("%p %u: ",ATOM_PTR(a),ATOM_LEN(a));-                        fwrite(ATOM_PTR(a),1,ATOM_LEN(a),stdout);-                        fwrite("\n",1,1,stdout);+                        if (fwrite(ATOM_PTR(a),1,ATOM_LEN(a),stdout)) return;+                        if (fwrite("\n",1,1,stdout)) return;                 }         } }
src/StringTable/AtomMap.hs view
@@ -263,9 +263,13 @@ mapEitherWithKey :: (Key -> a -> Either b c) -> AtomMap a -> (AtomMap b, AtomMap c) mapEitherWithKey x y = (\(x, y) -> (MkAtomMap x, MkAtomMap y)) (IM.mapEitherWithKey ((. unsafeIntToAtom) x) (fromAtomMap y)) maxViewWithKey :: (Monad m) => AtomMap a -> m ((Key, a), AtomMap a)-maxViewWithKey x = liftM (\((x, y), z) -> ((unsafeIntToAtom x, y), MkAtomMap z)) (IM.maxViewWithKey (fromAtomMap x))+maxViewWithKey x = case IM.maxViewWithKey (fromAtomMap x) of+    Just ((x, y), z) -> return ((unsafeIntToAtom x, y), MkAtomMap z) +    _ -> fail "No maxViewWithKey" minViewWithKey :: (Monad m) => AtomMap a -> m ((Key, a), AtomMap a)-minViewWithKey x = liftM (\((x, y), z) -> ((unsafeIntToAtom x, y), MkAtomMap z)) (IM.minViewWithKey (fromAtomMap x))+minViewWithKey x = case IM.minViewWithKey (fromAtomMap x) of+    Just ((x, y), z) -> return ((unsafeIntToAtom x, y), MkAtomMap z) +    _ -> fail "No minViewWithKey" notMember :: Key -> AtomMap a -> Bool notMember x y =  (IM.notMember (fromAtom x) (fromAtomMap y)) partition :: (a -> Bool) -> AtomMap a -> (AtomMap a,AtomMap a)@@ -305,9 +309,13 @@ alter :: (Maybe a -> Maybe a) -> Key -> AtomMap a -> AtomMap a alter x y z = MkAtomMap (IM.alter ( x) (fromAtom y) (fromAtomMap z)) maxView :: (Monad m) => AtomMap a -> m (a, AtomMap a)-maxView x = liftM (\(x, y) -> (x, MkAtomMap y)) (IM.maxView (fromAtomMap x))+maxView x = case IM.maxView (fromAtomMap x) of+    Just (x, y) -> return (x, MkAtomMap y)+    _ -> fail "No maxView" minView :: (Monad m) => AtomMap a -> m (a, AtomMap a)-minView x = liftM (\(x, y) -> (x, MkAtomMap y)) (IM.minView (fromAtomMap x))+minView x = case IM.minView (fromAtomMap x) of+    Just (x, y) -> return (x, MkAtomMap y)+    _ -> fail "No minView" findMax :: AtomMap a -> a findMax x =  (IM.findMax (fromAtomMap x)) findMin :: AtomMap a -> a
src/StringTable/AtomSet.hs view
@@ -119,9 +119,13 @@ deleteFindMax :: AtomSet -> (Atom, AtomSet) deleteFindMax x = (\(x, y) -> (unsafeIntToAtom x, MkAtomSet y)) (IS.deleteFindMax (fromAtomSet x)) maxView :: (Monad m) => AtomSet -> m (Atom, AtomSet)-maxView x = liftM (\(x, y) -> (unsafeIntToAtom x, MkAtomSet y)) (IS.maxView (fromAtomSet x))+maxView x = case IS.maxView (fromAtomSet x) of+    Just (x, y) -> return (unsafeIntToAtom x, MkAtomSet y)+    _ -> fail "No maxView" minView :: (Monad m) => AtomSet -> m (Atom, AtomSet)-minView x = liftM (\(x, y) -> (unsafeIntToAtom x, MkAtomSet y)) (IS.minView (fromAtomSet x))+minView x = case IS.minView (fromAtomSet x) of+    Just (x, y) -> return (unsafeIntToAtom x, MkAtomSet y)+    _ -> fail "No minView" map :: (Atom->Atom) -> AtomSet -> AtomSet map x y = MkAtomSet (IS.map ((\f -> fromAtom . f . unsafeIntToAtom) x) (fromAtomSet y)) fold :: (Atom -> b -> b) -> b -> AtomSet -> b
stringtable-atom.cabal view
@@ -1,5 +1,5 @@ Name:                stringtable-atom-Version:             0.0.4+Version:             0.0.5 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@@ -10,9 +10,9 @@ Copyright:           John Meacham 2008, Audrey Tang 2008 Exposed-modules:     StringTable.Atom StringTable.AtomMap StringTable.AtomSet -Build-Depends:       base, bytestring>=0.9.0.1, binary, containers+Build-Depends:       base<4, bytestring>=0.9.0.1, binary, containers Build-Type:          Simple-Tested-With:         GHC==6.8.2, GHC==6.8.3+Tested-With:         GHC==6.8.2, GHC==6.8.3, GHC==6.10.1  extensions:          ForeignFunctionInterface, TypeSynonymInstances,                      DeriveDataTypeable, FlexibleInstances,