exinst-serialise (empty) → 0.7
raw patch · 7 files changed
+416/−0 lines, 7 filesdep +QuickCheckdep +basedep +binarysetup-changed
Dependencies added: QuickCheck, base, binary, constraints, exinst, exinst-serialise, serialise, singletons, tasty, tasty-quickcheck
Files
- CHANGELOG.md +4/−0
- LICENSE.txt +30/−0
- README.md +4/−0
- Setup.hs +2/−0
- exinst-serialise.cabal +45/−0
- lib/Exinst/Serialise.hs +141/−0
- tests/Main.hs +190/−0
+ CHANGELOG.md view
@@ -0,0 +1,4 @@+# Version 0.7++* This library exports the `Codec.Serialise.Serialise` instances previously+ exported from `exinst-0.6`.
+ LICENSE.txt view
@@ -0,0 +1,30 @@+Copyright (c) 2015-2018, Renzo Carbonara++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Renzo Carbonara nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,4 @@+# exinst-serialise++See the [BSD3 LICENSE](https://github.com/k0001/exinst/blob/master/exinst/exinst-serialise/LICENSE.txt)+file to learn about the legal terms and conditions for this library.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ exinst-serialise.cabal view
@@ -0,0 +1,45 @@+name: exinst-serialise+version: 0.7+author: Renzo Carbonara+maintainer: renλren!zone+copyright: Renzo Carbonara 2015-2018+license: BSD3+license-file: LICENSE.txt+extra-source-files: README.md CHANGELOG.md+category: Data+build-type: Simple+cabal-version: >=1.18+synopsis: Dependent pairs and their instances.+homepage: https://github.com/k0001/exinst+bug-reports: https://github.com/k0001/exinst/issues+++library+ hs-source-dirs: lib+ default-language: Haskell2010+ exposed-modules: Exinst.Serialise+ build-depends:+ base >=4.9 && <5.0+ , serialise+ , constraints+ , exinst >=0.7+ , singletons+ ghcjs-options: -Wall -O3+ ghc-options: -Wall -O2++test-suite tests+ default-language: Haskell2010+ type: exitcode-stdio-1.0+ hs-source-dirs: tests+ main-is: Main.hs+ build-depends:+ base+ , binary+ , exinst+ , exinst-serialise+ , QuickCheck+ , serialise+ , tasty+ , tasty-quickcheck+ ghcjs-options: -Wall -O0+ ghc-options: -Wall -O0
+ lib/Exinst/Serialise.hs view
@@ -0,0 +1,141 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeInType #-}+{-# LANGUAGE UndecidableInstances #-}++{-# OPTIONS_GHC -fno-warn-orphans #-}++-- | This module exports 'Serialise' instances (which provide+-- binary serialisation via the CBOR format) for 'Some1',+-- 'Some2', 'Some3' and 'Some4' from "Exinst", provided situable+-- 'Dict1', 'Dict2', 'Dict3' and 'Dict4' instances are available.+--+-- See the README file in the @exinst@ package for more general documentation:+-- https://hackage.haskell.org/package/exinst#readme+module Exinst.Serialise () where++import Codec.Serialise+import Codec.Serialise.Decoding (decodeListLenOf)+import Data.Constraint+import Data.Kind (Type)+import Data.Singletons+import Prelude++import Exinst++--------------------------------------------------------------------------------++instance forall (f :: k1 -> Type)+ . ( SingKind k1+ , Serialise (Demote k1)+ , Dict1 Serialise f+ ) => Serialise (Some1 f)+ where+ {-# INLINABLE encode #-}+ encode = \some1x -> withSome1Sing some1x $ \sa1 (x :: f a1) ->+ case dict1 sa1 :: Dict (Serialise (f a1)) of+ Dict -> encode (fromSing sa1, x)+ {-# INLINABLE decode #-}+ decode = do+ decodeListLenOf 2+ rsa1 <- decode+ withSomeSing rsa1 $ \(sa1 :: Sing (a1 :: k1)) ->+ case dict1 sa1 :: Dict (Serialise (f a1)) of+ Dict -> do+ x :: f a1 <- decode+ pure (Some1 sa1 x)++instance forall (f :: k2 -> k1 -> Type)+ . ( SingKind k2+ , SingKind k1+ , Serialise (Demote k2)+ , Serialise (Demote k1)+ , Dict2 Serialise f+ ) => Serialise (Some2 f)+ where+ {-# INLINABLE encode #-}+ encode = \some2x -> withSome2Sing some2x $ \sa2 sa1 (x :: f a2 a1) ->+ case dict2 sa2 sa1 :: Dict (Serialise (f a2 a1)) of+ Dict -> encode (fromSing sa2, fromSing sa1, x)+++ {-# INLINABLE decode #-}+ decode = do+ decodeListLenOf 3+ rsa2 <- decode; rsa1 <- decode+ withSomeSing rsa2 $ \(sa2 :: Sing (a2 :: k2)) ->+ withSomeSing rsa1 $ \(sa1 :: Sing (a1 :: k1)) ->+ case dict2 sa2 sa1 :: Dict (Serialise (f a2 a1)) of+ Dict -> do+ x :: f a2 a1 <- decode+ pure (Some2 sa2 sa1 x)++instance forall (f :: k3 -> k2 -> k1 -> Type)+ . ( SingKind k3+ , SingKind k2+ , SingKind k1+ , Serialise (Demote k3)+ , Serialise (Demote k2)+ , Serialise (Demote k1)+ , Dict3 Serialise f+ ) => Serialise (Some3 f)+ where+ {-# INLINABLE encode #-}+ encode = \some3x -> withSome3Sing some3x $ \sa3 sa2 sa1 (x :: f a3 a2 a1) ->+ case dict3 sa3 sa2 sa1 :: Dict (Serialise (f a3 a2 a1)) of+ Dict -> encode (fromSing sa3, fromSing sa2, fromSing sa1, x)+ {-# INLINABLE decode #-}+ decode = do+ decodeListLenOf 4+ rsa3 <- decode; rsa2 <- decode; rsa1 <- decode+ withSomeSing rsa3 $ \(sa3 :: Sing (a3 :: k3)) ->+ withSomeSing rsa2 $ \(sa2 :: Sing (a2 :: k2)) ->+ withSomeSing rsa1 $ \(sa1 :: Sing (a1 :: k1)) ->+ case dict3 sa3 sa2 sa1 :: Dict (Serialise (f a3 a2 a1)) of+ Dict -> do+ x :: f a3 a2 a1 <- decode+ pure (Some3 sa3 sa2 sa1 x)++instance forall (f :: k4 -> k3 -> k2 -> k1 -> Type)+ . ( SingKind k4+ , SingKind k3+ , SingKind k2+ , SingKind k1+ , Serialise (Demote k4)+ , Serialise (Demote k3)+ , Serialise (Demote k2)+ , Serialise (Demote k1)+ , Dict4 Serialise f+ ) => Serialise (Some4 f)+ where+ {-# INLINABLE encode #-}+ encode = \some4x -> withSome4Sing some4x $ \sa4 sa3 sa2 sa1 (x :: f a4 a3 a2 a1) ->+ case dict4 sa4 sa3 sa2 sa1 :: Dict (Serialise (f a4 a3 a2 a1)) of+ Dict -> encode (fromSing sa4, fromSing sa3, fromSing sa2, fromSing sa1, x)+ {-# INLINABLE decode #-}+ decode = do+ decodeListLenOf 5+ rsa4 <- decode; rsa3 <- decode; rsa2 <- decode; rsa1 <- decode;+ withSomeSing rsa4 $ \(sa4 :: Sing (a4 :: k4)) ->+ withSomeSing rsa3 $ \(sa3 :: Sing (a3 :: k3)) ->+ withSomeSing rsa2 $ \(sa2 :: Sing (a2 :: k2)) ->+ withSomeSing rsa1 $ \(sa1 :: Sing (a1 :: k1)) ->+ case dict4 sa4 sa3 sa2 sa1 :: Dict (Serialise (f a4 a3 a2 a1)) of+ Dict -> do+ x :: f a4 a3 a2 a1 <- decode+ pure (Some4 sa4 sa3 sa2 sa1 x)++--------------------------------------------------------------------------------++instance (Serialise (l a1), Serialise (r a1)) => Serialise (S1 l r a1)+instance (Serialise (l a2 a1), Serialise (r a2 a1)) => Serialise (S2 l r a2 a1)+instance (Serialise (l a3 a2 a1), Serialise (r a3 a2 a1)) => Serialise (S3 l r a3 a2 a1)+instance (Serialise (l a4 a3 a2 a1), Serialise (r a4 a3 a2 a1)) => Serialise (S4 l r a4 a3 a2 a1)++--------------------------------------------------------------------------------++instance (Serialise (l a1), Serialise (r a1)) => Serialise (P1 l r a1)+instance (Serialise (l a2 a1), Serialise (r a2 a1)) => Serialise (P2 l r a2 a1)+instance (Serialise (l a3 a2 a1), Serialise (r a3 a2 a1)) => Serialise (P3 l r a3 a2 a1)+instance (Serialise (l a4 a3 a2 a1), Serialise (r a4 a3 a2 a1)) => Serialise (P4 l r a4 a3 a2 a1)
+ tests/Main.hs view
@@ -0,0 +1,190 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveAnyClass #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeFamilies #-}++module Main where++import qualified Codec.Serialise as Cborg+import Data.Int (Int32)+import Data.Kind (Type)+import qualified GHC.Generics as G+import qualified Test.Tasty as Tasty+import qualified Test.Tasty.Runners as Tasty+import Test.Tasty.QuickCheck ((===))+import qualified Test.Tasty.QuickCheck as QC++import Exinst+import Exinst.Serialise ()++--------------------------------------------------------------------------------++main :: IO ()+main = Tasty.defaultMainWithIngredients+ [ Tasty.consoleTestReporter+ , Tasty.listingTests+ ] tt++--------------------------------------------------------------------------------++data family X1 :: Bool -> Type+data instance X1 'False = XF1 | XF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X1 'True = XT1 | XT2 Int32 deriving (Eq, Show, Read, G.Generic)++data family X2 :: Bool -> Bool -> Type+data instance X2 'False 'False = XFF1 | XFF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X2 'False 'True = XFT1 | XFT2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X2 'True 'False = XTF1 | XTF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X2 'True 'True = XTT1 | XTT2 Int32 deriving (Eq, Show, Read, G.Generic)++data family X3 :: Bool -> Bool -> Bool -> Type+data instance X3 'False 'False 'False = XFFF1 | XFFF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X3 'False 'False 'True = XFFT1 | XFFT2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X3 'False 'True 'False = XFTF1 | XFTF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X3 'False 'True 'True = XFTT1 | XFTT2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X3 'True 'False 'False = XTFF1 | XTFF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X3 'True 'False 'True = XTFT1 | XTFT2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X3 'True 'True 'False = XTTF1 | XTTF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X3 'True 'True 'True = XTTT1 | XTTT2 Int32 deriving (Eq, Show, Read, G.Generic)++data family X4 :: Bool -> Bool -> Bool -> Bool -> Type+data instance X4 'False 'False 'False 'False = XFFFF1 | XFFFF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'False 'False 'False 'True = XFFFT1 | XFFFT2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'False 'False 'True 'False = XFFTF1 | XFFTF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'False 'False 'True 'True = XFFTT1 | XFFTT2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'False 'True 'False 'False = XFTFF1 | XFTFF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'False 'True 'False 'True = XFTFT1 | XFTFT2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'False 'True 'True 'False = XFTTF1 | XFTTF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'False 'True 'True 'True = XFTTT1 | XFTTT2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'True 'False 'False 'False = XTFFF1 | XTFFF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'True 'False 'False 'True = XTFFT1 | XTFFT2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'True 'False 'True 'False = XTFTF1 | XTFTF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'True 'False 'True 'True = XTFTT1 | XTFTT2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'True 'True 'False 'False = XTTFF1 | XTTFF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'True 'True 'False 'True = XTTFT1 | XTTFT2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'True 'True 'True 'False = XTTTF1 | XTTTF2 Int32 deriving (Eq, Show, Read, G.Generic)+data instance X4 'True 'True 'True 'True = XTTTT1 | XTTTT2 Int32 deriving (Eq, Show, Read, G.Generic)++#define INSTANCETRON(c) \+ instance c (X1 'False); \+ instance c (X1 'True); \+ instance c (X2 'False 'False); \+ instance c (X2 'False 'True); \+ instance c (X2 'True 'False); \+ instance c (X2 'True 'True); \+ instance c (X3 'False 'False 'False); \+ instance c (X3 'False 'False 'True); \+ instance c (X3 'False 'True 'False); \+ instance c (X3 'False 'True 'True); \+ instance c (X3 'True 'False 'False); \+ instance c (X3 'True 'False 'True); \+ instance c (X3 'True 'True 'False); \+ instance c (X3 'True 'True 'True); \+ instance c (X4 'False 'False 'False 'False); \+ instance c (X4 'False 'False 'False 'True); \+ instance c (X4 'False 'False 'True 'False); \+ instance c (X4 'False 'False 'True 'True); \+ instance c (X4 'False 'True 'False 'False); \+ instance c (X4 'False 'True 'False 'True); \+ instance c (X4 'False 'True 'True 'False); \+ instance c (X4 'False 'True 'True 'True); \+ instance c (X4 'True 'False 'False 'False); \+ instance c (X4 'True 'False 'False 'True); \+ instance c (X4 'True 'False 'True 'False); \+ instance c (X4 'True 'False 'True 'True); \+ instance c (X4 'True 'True 'False 'False); \+ instance c (X4 'True 'True 'False 'True); \+ instance c (X4 'True 'True 'True 'False); \+ instance c (X4 'True 'True 'True 'True)++--------------------------------------------------------------------------------+-- Arbitrary instances++instance QC.Arbitrary (X1 'False) where arbitrary = QC.oneof [ pure XF1, fmap XF2 QC.arbitrary ]+instance QC.Arbitrary (X1 'True) where arbitrary = QC.oneof [ pure XT1, fmap XT2 QC.arbitrary ]++instance QC.Arbitrary (X2 'False 'False) where arbitrary = QC.oneof [ pure XFF1, fmap XFF2 QC.arbitrary ]+instance QC.Arbitrary (X2 'False 'True) where arbitrary = QC.oneof [ pure XFT1, fmap XFT2 QC.arbitrary ]+instance QC.Arbitrary (X2 'True 'False) where arbitrary = QC.oneof [ pure XTF1, fmap XTF2 QC.arbitrary ]+instance QC.Arbitrary (X2 'True 'True) where arbitrary = QC.oneof [ pure XTT1, fmap XTT2 QC.arbitrary ]++instance QC.Arbitrary (X3 'False 'False 'False) where arbitrary = QC.oneof [ pure XFFF1, fmap XFFF2 QC.arbitrary ]+instance QC.Arbitrary (X3 'False 'False 'True) where arbitrary = QC.oneof [ pure XFFT1, fmap XFFT2 QC.arbitrary ]+instance QC.Arbitrary (X3 'False 'True 'False) where arbitrary = QC.oneof [ pure XFTF1, fmap XFTF2 QC.arbitrary ]+instance QC.Arbitrary (X3 'False 'True 'True) where arbitrary = QC.oneof [ pure XFTT1, fmap XFTT2 QC.arbitrary ]+instance QC.Arbitrary (X3 'True 'False 'False) where arbitrary = QC.oneof [ pure XTFF1, fmap XTFF2 QC.arbitrary ]+instance QC.Arbitrary (X3 'True 'False 'True) where arbitrary = QC.oneof [ pure XTFT1, fmap XTFT2 QC.arbitrary ]+instance QC.Arbitrary (X3 'True 'True 'False) where arbitrary = QC.oneof [ pure XTTF1, fmap XTTF2 QC.arbitrary ]+instance QC.Arbitrary (X3 'True 'True 'True) where arbitrary = QC.oneof [ pure XTTT1, fmap XTTT2 QC.arbitrary ]++instance QC.Arbitrary (X4 'False 'False 'False 'False) where arbitrary = QC.oneof [ pure XFFFF1, fmap XFFFF2 QC.arbitrary ]+instance QC.Arbitrary (X4 'False 'False 'False 'True) where arbitrary = QC.oneof [ pure XFFFT1, fmap XFFFT2 QC.arbitrary ]+instance QC.Arbitrary (X4 'False 'False 'True 'False) where arbitrary = QC.oneof [ pure XFFTF1, fmap XFFTF2 QC.arbitrary ]+instance QC.Arbitrary (X4 'False 'False 'True 'True) where arbitrary = QC.oneof [ pure XFFTT1, fmap XFFTT2 QC.arbitrary ]+instance QC.Arbitrary (X4 'False 'True 'False 'False) where arbitrary = QC.oneof [ pure XFTFF1, fmap XFTFF2 QC.arbitrary ]+instance QC.Arbitrary (X4 'False 'True 'False 'True) where arbitrary = QC.oneof [ pure XFTFT1, fmap XFTFT2 QC.arbitrary ]+instance QC.Arbitrary (X4 'False 'True 'True 'False) where arbitrary = QC.oneof [ pure XFTTF1, fmap XFTTF2 QC.arbitrary ]+instance QC.Arbitrary (X4 'False 'True 'True 'True) where arbitrary = QC.oneof [ pure XFTTT1, fmap XFTTT2 QC.arbitrary ]+instance QC.Arbitrary (X4 'True 'False 'False 'False) where arbitrary = QC.oneof [ pure XTFFF1, fmap XTFFF2 QC.arbitrary ]+instance QC.Arbitrary (X4 'True 'False 'False 'True) where arbitrary = QC.oneof [ pure XTFFT1, fmap XTFFT2 QC.arbitrary ]+instance QC.Arbitrary (X4 'True 'False 'True 'False) where arbitrary = QC.oneof [ pure XTFTF1, fmap XTFTF2 QC.arbitrary ]+instance QC.Arbitrary (X4 'True 'False 'True 'True) where arbitrary = QC.oneof [ pure XTFTT1, fmap XTFTT2 QC.arbitrary ]+instance QC.Arbitrary (X4 'True 'True 'False 'False) where arbitrary = QC.oneof [ pure XTTFF1, fmap XTTFF2 QC.arbitrary ]+instance QC.Arbitrary (X4 'True 'True 'False 'True) where arbitrary = QC.oneof [ pure XTTFT1, fmap XTTFT2 QC.arbitrary ]+instance QC.Arbitrary (X4 'True 'True 'True 'False) where arbitrary = QC.oneof [ pure XTTTF1, fmap XTTTF2 QC.arbitrary ]+instance QC.Arbitrary (X4 'True 'True 'True 'True) where arbitrary = QC.oneof [ pure XTTTT1, fmap XTTTT2 QC.arbitrary ]++--------------------------------------------------------------------------------++tt :: Tasty.TestTree+tt =+ Tasty.testGroup "main"+ [ tt_id "Identity through serialise's Serialise" id_serialise+ ]++tt_id+ :: String+ -> (forall a. Cborg.Serialise a => a -> Maybe a)+ -- ^ It's easier to put all the constraints here in the 'MegaCtx' monster.+ -> Tasty.TestTree+tt_id = \title id' -> Tasty.testGroup title+ [ QC.testProperty "Some1 X1" $+ QC.forAll QC.arbitrary $ \(x :: Some1 X1) -> Just x === id' x+ , QC.testProperty "Some2 X2" $+ QC.forAll QC.arbitrary $ \(x :: Some2 X2) -> Just x === id' x+ , QC.testProperty "Some3 X3" $+ QC.forAll QC.arbitrary $ \(x :: Some3 X3) -> Just x === id' x+ , QC.testProperty "Some4 X4" $+ QC.forAll QC.arbitrary $ \(x :: Some4 X4) -> Just x === id' x+ , QC.testProperty "Some1 (P1 X1 X1)" $+ QC.forAll QC.arbitrary $ \(x :: Some1 (P1 X1 X1)) -> Just x === id' x+ , QC.testProperty "Some2 (P2 X2 X2)" $+ QC.forAll QC.arbitrary $ \(x :: Some2 (P2 X2 X2)) -> Just x === id' x+ , QC.testProperty "Some3 (P3 X3 X3)" $+ QC.forAll QC.arbitrary $ \(x :: Some3 (P3 X3 X3)) -> Just x === id' x+ , QC.testProperty "Some4 (P4 X4 X4)" $+ QC.forAll QC.arbitrary $ \(x :: Some4 (P4 X4 X4)) -> Just x === id' x+ , QC.testProperty "Some1 (S1 X1 X1)" $+ QC.forAll QC.arbitrary $ \(x :: Some1 (S1 X1 X1)) -> Just x === id' x+ , QC.testProperty "Some2 (S2 X2 X2)" $+ QC.forAll QC.arbitrary $ \(x :: Some2 (S2 X2 X2)) -> Just x === id' x+ , QC.testProperty "Some3 (S3 X3 X3)" $+ QC.forAll QC.arbitrary $ \(x :: Some3 (S3 X3 X3)) -> Just x === id' x+ , QC.testProperty "Some4 (S4 X4 X4)" $+ QC.forAll QC.arbitrary $ \(x :: Some4 (S4 X4 X4)) -> Just x === id' x+ ]+++--------------------------------------------------------------------------------++INSTANCETRON(Cborg.Serialise)+id_serialise :: Cborg.Serialise a => a -> Maybe a+id_serialise = \a ->+ case Cborg.deserialiseOrFail (Cborg.serialise a) of+ Right a' -> Just a'+ Left _ -> Nothing