msgpack 0.7.0 → 0.7.1
raw patch · 3 files changed
+94/−33 lines, 3 filesdep +msgpackdep ~basedep ~deepseqdep ~template-haskellPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: msgpack
Dependency ranges changed: base, deepseq, template-haskell, test-framework
API changes (from Hackage documentation)
- Data.MessagePack.Object: class (Unpackable a, Packable a) => OBJECT a
+ Data.MessagePack.Object: class (Unpackable a, Packable a) => OBJECT a where toObject = unpack . pack fromObject a = case tryFromObject a of { Left err -> throw $ UnpackError err Right ret -> ret } tryFromObject = tryUnpack . pack
Files
- Data/MessagePack/Pack.hs +3/−5
- msgpack.cabal +21/−28
- test/Test.hs +70/−0
Data/MessagePack/Pack.hs view
@@ -34,14 +34,12 @@ import qualified Data.Text.Lazy as TL import qualified Data.Text.Lazy.Encoding as TL import qualified Data.Vector as V-import Foreign+import Foreign hiding (unsafeLocalState)+import Foreign.Marshal.Unsafe import Data.MessagePack.Assoc import Data.MessagePack.Internal.Utf8 -(<>) :: Monoid m => m -> m -> m-(<>) = mappend- -- | Serializable class class Packable a where -- | Serialize a value@@ -102,7 +100,7 @@ fromWord64be (cast d) cast :: (Storable a, Storable b) => a -> b-cast v = unsafePerformIO $ with v $ peek . castPtr+cast v = unsafeLocalState $ with v $ peek . castPtr instance Packable String where from = fromString encodeUtf8 B.length fromByteString
msgpack.cabal view
@@ -1,5 +1,5 @@ Name: msgpack-Version: 0.7.0+Version: 0.7.1 Synopsis: A Haskell implementation of MessagePack Description: A Haskell implementation of MessagePack <http://msgpack.org/> Homepage: http://msgpack.org/@@ -18,18 +18,18 @@ Location: git://github.com/msgpack/msgpack-haskell.git Library- Build-depends: base >=4 && <5- , mtl >= 2.0 && < 2.1- , bytestring >= 0.9 && < 0.10- , text >= 0.11 && < 0.12- , containers >= 0.4 && < 0.5- , unordered-containers >= 0.1 && < 0.2- , hashable >= 1.1 && < 1.2- , vector >= 0.7 && < 0.10- , attoparsec >= 0.8 && < 0.11+ Build-depends: base == 4.*+ , mtl == 2.0.*+ , bytestring == 0.9.*+ , text == 0.11.*+ , containers == 0.4.*+ , unordered-containers == 0.1.*+ , hashable == 1.1.*+ , vector >= 0.7 && < 0.10+ , attoparsec >= 0.8 && < 0.11 , blaze-builder >= 0.3 && < 0.4- , deepseq >= 1.1 && <1.3- , template-haskell >= 2.4 && < 2.7+ , deepseq >= 1.1 && <1.4+ , template-haskell >= 2.4 && < 2.8 Ghc-options: -Wall @@ -43,19 +43,12 @@ Test-suite msgpack-tests Type: exitcode-stdio-1.0- Main-is: test/Test.hs- Build-depends: base >= 4 && < 5- , mtl >= 2.0 && < 2.1- , bytestring >= 0.9 && < 0.10- , text >= 0.11 && < 0.12- , containers >= 0.4 && < 0.5- , unordered-containers >= 0.1 && < 0.2- , hashable >= 1.1 && < 1.2- , vector >= 0.7 && < 0.10- , attoparsec >= 0.8 && < 0.11- , blaze-builder >= 0.3 && < 0.4- , deepseq >= 1.1 && <1.3- , template-haskell >= 2.4 && < 2.7- , QuickCheck >= 2.4 && < 2.5- , test-framework >= 0.4 && < 0.5- , test-framework-quickcheck2 >= 0.2 && < 0.3+ Hs-source-dirs: test+ Main-is: Test.hs++ Build-depends: base == 4.*+ , bytestring == 0.9.*+ , QuickCheck == 2.4.*+ , test-framework == 0.5.*+ , test-framework-quickcheck2 == 0.2.*+ , msgpack
+ test/Test.hs view
@@ -0,0 +1,70 @@+import Test.Framework+import Test.Framework.Providers.QuickCheck2+import Test.QuickCheck++import Control.Monad+import qualified Data.ByteString.Char8 as B+import qualified Data.ByteString.Lazy.Char8 as L+import Data.MessagePack++instance Arbitrary a => Arbitrary (Assoc a) where+ arbitrary = liftM Assoc arbitrary++mid :: (Packable a, Unpackable a) => a -> a+mid = unpack . pack++prop_mid_int a = a == mid a+ where types = a :: Int+prop_mid_nil a = a == mid a+ where types = a :: ()+prop_mid_bool a = a == mid a+ where types = a :: Bool+prop_mid_double a = a == mid a+ where types = a :: Double+prop_mid_string a = a == mid a+ where types = a :: String+prop_mid_bytestring a = B.pack a == mid (B.pack a)+ where types = a :: String+prop_mid_lazy_bytestring a = (L.pack a) == mid (L.pack a)+ where types = a :: String+prop_mid_array_int a = a == mid a+ where types = a :: [Int]+prop_mid_array_string a = a == mid a+ where types = a :: [String]+prop_mid_pair2 a = a == mid a+ where types = a :: (Int, Int)+prop_mid_pair3 a = a == mid a+ where types = a :: (Int, Int, Int)+prop_mid_pair4 a = a == mid a+ where types = a :: (Int, Int, Int, Int)+prop_mid_pair5 a = a == mid a+ where types = a :: (Int, Int, Int, Int, Int)+prop_mid_list_int_double a = a == mid a+ where types = a :: [(Int, Double)]+prop_mid_list_string_string a = a == mid a+ where types = a :: [(String, String)]+prop_mid_map_string_int a = a == mid a+ where types = a :: Assoc [(String,Int)]++tests =+ [ testGroup "simple"+ [ testProperty "int" prop_mid_int+ , testProperty "nil" prop_mid_nil+ , testProperty "bool" prop_mid_bool+ , testProperty "double" prop_mid_double+ , testProperty "string" prop_mid_string+ , testProperty "bytestring" prop_mid_bytestring+ , testProperty "lazy-bytestring" prop_mid_lazy_bytestring+ , testProperty "[int]" prop_mid_array_int+ , testProperty "[string]" prop_mid_array_string+ , testProperty "(int, int)" prop_mid_pair2+ , testProperty "(int, int, int)" prop_mid_pair3+ , testProperty "(int, int, int, int)" prop_mid_pair4+ , testProperty "(int, int, int, int, int)" prop_mid_pair5+ , testProperty "[(int, double)]" prop_mid_list_int_double+ , testProperty "[(string, string)]" prop_mid_list_string_string+ , testProperty "Assoc [(string, int)]" prop_mid_map_string_int+ ]+ ]++main = defaultMain tests