| Copyright | (c) Duncan Coutts 2015-2017 |
|---|---|
| License | BSD3-style (see LICENSE.txt) |
| Maintainer | duncan@community.haskell.org |
| Stability | experimental |
| Portability | non-portable (GHC extensions) |
| Safe Haskell | None |
| Language | Haskell2010 |
Codec.Serialise.Properties
Description
This module contains a set of generally useful properties, which
instance authors are encouraged to use in order to test their
instances of the class. For example, if you have a
data type which you might derive or write instances for:Serialise
data Foo = Foo { fooInt :: Int, fooBool :: Bool }
deriving (Eq, Show, Generic)
-- or, alternatively
instance Serialise Foo where
encode = ...
decode = ...
Then you can use this module to easily derive some quick properties:
import qualified Codec.Serialise.Properties as Props fooSerialiseId :: Foo -> Bool fooSerialiseId = Props.serialiseIdentityfooFlatTermId :: Foo -> Bool fooFlatTermId = Props.flatTermIdentityfooHasValidFlatTerm :: Foo -> Bool fooHasValidFlatTerm = Props.hasValidFlatTerm
You can then conveniently use these three functions with QuickCheck, for example.
- serialiseIdentity :: (Serialise a, Eq a) => a -> Bool
- flatTermIdentity :: (Serialise a, Eq a) => a -> Bool
- hasValidFlatTerm :: Serialise a => a -> Bool
CBOR Properties
serialiseIdentity :: (Serialise a, Eq a) => a -> Bool Source #
Ensure that serializing and deserializing some value results in the original value being returned.
Since: 0.2.0.0
FlatTerm Properties
FlatTerm