monad-atom 0.2.0 → 0.3.0
raw patch · 2 files changed
+16/−14 lines, 2 filesdep +cerealdep −binaryPVP ok
version bump matches the API change (PVP)
Dependencies added: cereal
Dependencies removed: binary
API changes (from Hackage documentation)
- Control.Monad.Atom: instance Binary AtomTable
+ Control.Monad.Atom: instance Serialize AtomTable
- Control.Monad.Atom: fromAtom :: (MonadAtom m, Binary a) => Int -> m a
+ Control.Monad.Atom: fromAtom :: (MonadAtom m, Serialize a) => Int -> m a
- Control.Monad.Atom: maybeToAtom :: (MonadAtom m, Binary a) => a -> m (Maybe Int)
+ Control.Monad.Atom: maybeToAtom :: (MonadAtom m, Serialize a) => a -> m (Maybe Int)
- Control.Monad.Atom: toAtom :: (MonadAtom m, Binary a) => a -> m Int
+ Control.Monad.Atom: toAtom :: (MonadAtom m, Serialize a) => a -> m Int
Files
- Control/Monad/Atom.hs +14/−12
- monad-atom.cabal +2/−2
Control/Monad/Atom.hs view
@@ -18,9 +18,9 @@ import Control.Monad.Identity import qualified Data.Map as Map import qualified Data.IntMap as IntMap-import qualified Data.Binary as B+import qualified Data.Serialize as Serialize+import Data.Serialize (Serialize) import qualified Data.ByteString as Strict-import qualified Data.ByteString.Lazy as Lazy type Blob = Strict.ByteString @@ -30,22 +30,22 @@ -instance B.Binary AtomTable where- put t = do B.put (lastID t) - B.put (to t)- B.put (from t)- get = do liftM3 T B.get B.get B.get+instance Serialize AtomTable where+ put t = do Serialize.put (lastID t) + Serialize.put (to t)+ Serialize.put (from t)+ get = do liftM3 T Serialize.get Serialize.get Serialize.get class Monad m => MonadAtom m where -- | Monadically convert the argument into an atom (represented as an Int)- toAtom :: B.Binary a => a -> m Int+ toAtom :: Serialize a => a -> m Int -- | Monadically convert the argument into an atom, but only if -- the corresponding atom has already been created- maybeToAtom :: B.Binary a => a -> m (Maybe Int)+ maybeToAtom :: Serialize a => a -> m (Maybe Int) -- | Monadically convert an atom represented as an Int to its -- corresponding object- fromAtom :: B.Binary a => Int -> m a+ fromAtom :: Serialize a => Int -> m a instance Monad m => MonadAtom (AtomT m) where@@ -100,8 +100,10 @@ atoms :: AtomTable -> [Int] atoms = IntMap.keys . from -enc = Strict.concat . Lazy.toChunks . B.encode-dec = B.decode . Lazy.fromChunks . return+enc = Serialize.encode+dec bs = case Serialize.decode bs of+ Left err -> error (show err)+ Right r -> r example :: [String] example = evalAtom $ do
monad-atom.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.2.0+Version: 0.3.0 -- A short (one-line) description of the package. Synopsis: Monadically convert objects to unique atoms and back.@@ -48,7 +48,7 @@ Exposed-modules: Control.Monad.Atom -- Packages needed in order to build this package.- Build-depends: base >= 3 && < 5, bytestring >= 0.9, binary >= 0.5,+ Build-depends: base >= 3 && < 5, bytestring >= 0.9, cereal >= 0.3.5, containers >= 0.4, mtl >= 2.0 -- Modules not exported by this package.