packages feed

safecopy 0.2 → 0.3

raw patch · 3 files changed

+59/−2 lines, 3 filesdep +bytestringdep +containersdep ~base

Dependencies added: bytestring, containers

Dependency ranges changed: base

Files

safecopy.cabal view
@@ -1,5 +1,5 @@ Name:                safecopy-Version:             0.2+Version:             0.3 Synopsis:            Binary serialization with version control. Description:         An extension to Data.Binary with built-in version control. Category:            Data, Parsing@@ -7,7 +7,8 @@ License-file:        LICENSE Author:              David Himmelstrup Maintainer:          lemmih@gmail.com-Build-Depends:       base, mtl, binary+Build-Depends:       base, mtl, bytestring, containers, binary+Build-Type:          Simple ghc-options:         -O -fglasgow-exts Hs-Source-Dirs:      src Exposed-Modules:
src/Data/SafeCopy/Instances.hs view
@@ -13,6 +13,7 @@ import qualified Data.Set as Set  import qualified Data.ByteString.Lazy.Char8 as L+import qualified Data.ByteString.Char8 as B  import Control.Monad @@ -71,6 +72,8 @@ instance SafeCopy Double where     mode = Primitive; getCopy = contain $ get; putCopy = contain . put instance SafeCopy L.ByteString where+    mode = Primitive; getCopy = contain $ get; putCopy = contain . put+instance SafeCopy B.ByteString where     mode = Primitive; getCopy = contain $ get; putCopy = contain . put instance SafeCopy Char where     mode = Primitive; getCopy = contain $ get; putCopy = contain . put
src/Data/SafeCopy/Types.hs view
@@ -95,3 +95,56 @@  compareVersions :: Version a -> Version b -> Ordering compareVersions v1 v2 = compare (unVersion v1) (unVersion v2)++++{-++class Versioned a where+    typeVersion :: a -> Int++data Test1 a = Test1 a+data Test2 a = Test2 a++data Sub1 = Sub1 Int; instance Versioned Sub1 where typeVersion _ = 1+data Sub2 = Sub2 String; instance Versioned Sub2 where typeVersion _ = 2++showVersion (Test1 s) = typeVersion s+-}+{-+class HotSwap a where+    hotVersion :: Version a+    hotVersion = 0+    destruct :: a -> (Int,ArgList)+    construct :: (Int,ArgList) -> a++data Test = Test Sub1 Sub2+data Sub1 = Sub1+data Sub2 = Sub2++data ArgList = Nil | forall a. HotSwap a => a :+: ArgList++infixr 5 :+:++instance HotSwap Test where+    destruct (Test a b) = (1, a :+: b :+: Nil)+    construct (1, a :+: b :+: Nil) = Test (fromHot a) (fromHot b)++instance HotSwap Sub1 where+    destruct Sub1 = (1,Nil)+    construct (1,Nil) = Sub1+instance HotSwap Sub2 where+    destruct Sub2= (1,Nil)+    construct (1,Nil) = Sub2++fromHot :: (HotSwap a, HotSwap b) => a -> b+fromHot = undefined++{-+hotSwap :: forall a b. (HotSwap a, HotSwap b) => a -> b+hotSwap inp+    = let inpVersion = hotVersion :: Version a+          outVersion = hotVersion :: Version b+      in +-}+-}