binary-tagged-0.1.4.2: Tagged binary serialisation.

Copyright | (C) 2015 Oleg Grenrus
License | BSD3
Maintainer | Oleg Grenrus <oleg.grenrus@iki.fi>
Safe Haskell | None
Language | Haskell2010

Data.Binary.Tagged

Contents

- Data
- Serialisation
- IO functions for serialisation
- Class
  - Type level calculations
- Generic derivation
  - GHC
  - SOP
  - SOP direct
- Hash

Description

Structurally tag binary serialisation stream.

Say you have:

    data Record = Record
      { _recordFields :: HM.HashMap Text (Integer, ByteString)
      , _recordEnabled :: Bool
      }
      deriving (Eq, Show, Generic)

    instance Binary Record
    instance HasStructuralInfo Record
    instance HasSemanticVersion Record

then you can serialise and deserialise `Record` values with a structure tag by simply

    encodeTaggedFile "cachefile" record
    decodeTaggedFile "cachefile" :: IO Record

If structure of `Record` changes in between, deserialisation will fail early.

Synopsis

- newtype BinaryTagged v a = BinaryTagged {
  - unBinaryTagged :: a
  }
- type BinaryTagged' a = BinaryTagged (SemanticVersion a) a
- binaryTag :: Proxy v -> a -> BinaryTagged v a
- binaryTag' :: HasSemanticVersion a => a -> BinaryTagged' a
- binaryUntag :: Proxy v -> BinaryTagged v a -> a
- binaryUntag' :: HasSemanticVersion a => BinaryTagged' a -> a
- data StructuralInfo
  - = NominalType String
  - | NominalNewtype String StructuralInfo
  - | StructuralInfo String [[StructuralInfo]]
- taggedEncode :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => a -> ByteString
- taggedDecode :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => ByteString -> a
- taggedDecodeOrFail :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => ByteString -> Either (ByteString, ByteOffset, String) (ByteString, ByteOffset, a)
- taggedEncodeFile :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => FilePath -> a -> IO ()
- taggedDecodeFile :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => FilePath -> IO a
- taggedDecodeFileOrFail :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => FilePath -> IO (Either (ByteOffset, String) a)
- class HasStructuralInfo a where
- class KnownNat (SemanticVersion a) => HasSemanticVersion a where
  - type SemanticVersion a :: Nat
- type Version = Word32
- type Interleave n m = SumUpTo (n + m) + m
- type SumUpTo n = Div2 (n * (n + 1))
- type family Div2 (n :: Nat) :: Nat where ...
- ghcStructuralInfo :: (Generic a, All2 HasStructuralInfo (GCode a), GDatatypeInfo a, SListI2 (GCode a)) => Proxy a -> StructuralInfo
- ghcNominalType :: (Generic a, GDatatypeInfo a) => Proxy a -> StructuralInfo
- ghcStructuralInfo1 :: forall f a. (Generic1 f, GDatatypeInfo (f a), HasStructuralInfo a) => Proxy (f a) -> StructuralInfo
- sopStructuralInfo :: forall a. (Generic a, HasDatatypeInfo a, All2 HasStructuralInfo (Code a)) => Proxy a -> StructuralInfo
- sopNominalType :: forall a. (Generic a, HasDatatypeInfo a) => Proxy a -> StructuralInfo
- sopStructuralInfo1 :: forall f a. (Generic (f a), HasDatatypeInfo (f a), HasStructuralInfo a) => Proxy (f a) -> StructuralInfo
- sopStructuralInfoS :: forall xss. (All2 HasStructuralInfo xss, SListI2 xss) => DatatypeInfo xss -> StructuralInfo
- sopNominalTypeS :: DatatypeInfo xss -> StructuralInfo
- sopStructuralInfo1S :: StructuralInfo -> DatatypeInfo xss -> StructuralInfo
- structuralInfoSha1Digest :: StructuralInfo -> Digest SHA1State
- structuralInfoSha1ByteStringDigest :: StructuralInfo -> ByteString

# Data

newtype BinaryTagged v a #

`Binary` serialisable class, which tries to be less error-prone to data structure changes.

Values are serialised with header consisting of version `v` and hash of `structuralInfo`.

Constructors

BinaryTagged |
Fields unBinaryTagged :: a

Instances

Monad (BinaryTagged k v) # |
Methods (>>=) :: BinaryTagged k v a -> (a -> BinaryTagged k v b) -> BinaryTagged k v b # (>>) :: BinaryTagged k v a -> BinaryTagged k v b -> BinaryTagged k v b # return :: a -> BinaryTagged k v a # fail :: String -> BinaryTagged k v a #
Functor (BinaryTagged k v) # |
Methods fmap :: (a -> b) -> BinaryTagged k v a -> BinaryTagged k v b # (<$) :: a -> BinaryTagged k v b -> BinaryTagged k v a #
Applicative (BinaryTagged k v) # |
Methods pure :: a -> BinaryTagged k v a # (<*>) :: BinaryTagged k v (a -> b) -> BinaryTagged k v a -> BinaryTagged k v b # (*>) :: BinaryTagged k v a -> BinaryTagged k v b -> BinaryTagged k v b # (<*) :: BinaryTagged k v a -> BinaryTagged k v b -> BinaryTagged k v a #
Foldable (BinaryTagged k v) # |
Methods fold :: Monoid m => BinaryTagged k v m -> m # foldMap :: Monoid m => (a -> m) -> BinaryTagged k v a -> m # foldr :: (a -> b -> b) -> b -> BinaryTagged k v a -> b # foldr' :: (a -> b -> b) -> b -> BinaryTagged k v a -> b # foldl :: (b -> a -> b) -> b -> BinaryTagged k v a -> b # foldl' :: (b -> a -> b) -> b -> BinaryTagged k v a -> b # foldr1 :: (a -> a -> a) -> BinaryTagged k v a -> a # foldl1 :: (a -> a -> a) -> BinaryTagged k v a -> a # toList :: BinaryTagged k v a -> [a] # null :: BinaryTagged k v a -> Bool # length :: BinaryTagged k v a -> Int # elem :: Eq a => a -> BinaryTagged k v a -> Bool # maximum :: Ord a => BinaryTagged k v a -> a # minimum :: Ord a => BinaryTagged k v a -> a # sum :: Num a => BinaryTagged k v a -> a # product :: Num a => BinaryTagged k v a -> a #
Traversable (BinaryTagged k v) # |
Methods traverse :: Applicative f => (a -> f b) -> BinaryTagged k v a -> f (BinaryTagged k v b) # sequenceA :: Applicative f => BinaryTagged k v (f a) -> f (BinaryTagged k v a) # mapM :: Monad m => (a -> m b) -> BinaryTagged k v a -> m (BinaryTagged k v b) # sequence :: Monad m => BinaryTagged k v (m a) -> m (BinaryTagged k v a) #
Generic1 (BinaryTagged k v) # |
Associated Types type Rep1 (BinaryTagged k v :: * -> *) :: * -> * # Methods from1 :: BinaryTagged k v a -> Rep1 (BinaryTagged k v) a # to1 :: Rep1 (BinaryTagged k v) a -> BinaryTagged k v a #
Eq a => Eq (BinaryTagged k v a) # |
Methods (==) :: BinaryTagged k v a -> BinaryTagged k v a -> Bool # (/=) :: BinaryTagged k v a -> BinaryTagged k v a -> Bool #
Ord a => Ord (BinaryTagged k v a) # |
Methods compare :: BinaryTagged k v a -> BinaryTagged k v a -> Ordering # (<) :: BinaryTagged k v a -> BinaryTagged k v a -> Bool # (<=) :: BinaryTagged k v a -> BinaryTagged k v a -> Bool # (>) :: BinaryTagged k v a -> BinaryTagged k v a -> Bool # (>=) :: BinaryTagged k v a -> BinaryTagged k v a -> Bool # max :: BinaryTagged k v a -> BinaryTagged k v a -> BinaryTagged k v a # min :: BinaryTagged k v a -> BinaryTagged k v a -> BinaryTagged k v a #
Read a => Read (BinaryTagged k v a) # |
Methods readsPrec :: Int -> ReadS (BinaryTagged k v a) # readList :: ReadS [BinaryTagged k v a] # readPrec :: ReadPrec (BinaryTagged k v a) # readListPrec :: ReadPrec [BinaryTagged k v a] #
Show a => Show (BinaryTagged k v a) # |
Methods showsPrec :: Int -> BinaryTagged k v a -> ShowS # show :: BinaryTagged k v a -> String # showList :: [BinaryTagged k v a] -> ShowS #
Generic (BinaryTagged k v a) # |
Associated Types type Rep (BinaryTagged k v a) :: * -> * # Methods from :: BinaryTagged k v a -> Rep (BinaryTagged k v a) x # to :: Rep (BinaryTagged k v a) x -> BinaryTagged k v a #
Monoid a => Monoid (BinaryTagged k v a) # |
Methods mempty :: BinaryTagged k v a # mappend :: BinaryTagged k v a -> BinaryTagged k v a -> BinaryTagged k v a # mconcat :: [BinaryTagged k v a] -> BinaryTagged k v a #
(Binary a, HasStructuralInfo a, KnownNat v) => Binary (BinaryTagged Nat v a) # | Version and structure hash are prepended to serialised stream
Methods put :: BinaryTagged Nat v a -> Put # get :: Get (BinaryTagged Nat v a) # putList :: [BinaryTagged Nat v a] -> Put #
type Rep1 (BinaryTagged k v) # |
type Rep1 (BinaryTagged k v) = D1 (MetaData "BinaryTagged" "Data.Binary.Tagged" "binary-tagged-0.1.4.2-1O2piKnaZRG3wJzHfDXO9o" True) (C1 (MetaCons "BinaryTagged" PrefixI True) (S1 (MetaSel (Just Symbol "unBinaryTagged") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))
type Rep (BinaryTagged k v a) # |
type Rep (BinaryTagged k v a) = D1 (MetaData "BinaryTagged" "Data.Binary.Tagged" "binary-tagged-0.1.4.2-1O2piKnaZRG3wJzHfDXO9o" True) (C1 (MetaCons "BinaryTagged" PrefixI True) (S1 (MetaSel (Just Symbol "unBinaryTagged") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

type BinaryTagged' a = BinaryTagged (SemanticVersion a) a #

binaryTag :: Proxy v -> a -> BinaryTagged v a #

binaryTag' :: HasSemanticVersion a => a -> BinaryTagged' a #

binaryUntag :: Proxy v -> BinaryTagged v a -> a #

binaryUntag' :: HasSemanticVersion a => BinaryTagged' a -> a #

data StructuralInfo #

Data type structure, with (some) nominal information.

Constructors

NominalType String |
NominalNewtype String StructuralInfo |
StructuralInfo String [[StructuralInfo]] |

Instances

Eq StructuralInfo # |
Methods (==) :: StructuralInfo -> StructuralInfo -> Bool # (/=) :: StructuralInfo -> StructuralInfo -> Bool #
Ord StructuralInfo # |
Methods compare :: StructuralInfo -> StructuralInfo -> Ordering # (<) :: StructuralInfo -> StructuralInfo -> Bool # (<=) :: StructuralInfo -> StructuralInfo -> Bool # (>) :: StructuralInfo -> StructuralInfo -> Bool # (>=) :: StructuralInfo -> StructuralInfo -> Bool # max :: StructuralInfo -> StructuralInfo -> StructuralInfo # min :: StructuralInfo -> StructuralInfo -> StructuralInfo #
Show StructuralInfo # |
Methods showsPrec :: Int -> StructuralInfo -> ShowS # show :: StructuralInfo -> String # showList :: [StructuralInfo] -> ShowS #
Generic StructuralInfo # |
Associated Types type Rep StructuralInfo :: * -> * # Methods from :: StructuralInfo -> Rep StructuralInfo x # to :: Rep StructuralInfo x -> StructuralInfo #
Binary StructuralInfo # |
Methods put :: StructuralInfo -> Put # get :: Get StructuralInfo # putList :: [StructuralInfo] -> Put #
HasSemanticVersion StructuralInfo # |
Associated Types type SemanticVersion StructuralInfo :: Nat #
HasStructuralInfo StructuralInfo # |
Methods structuralInfo :: Proxy * StructuralInfo -> StructuralInfo #
type Rep StructuralInfo # |
type Rep StructuralInfo = D1 (MetaData "StructuralInfo" "Data.Binary.Tagged" "binary-tagged-0.1.4.2-1O2piKnaZRG3wJzHfDXO9o" False) ((:+:) (C1 (MetaCons "NominalType" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))) ((:+:) (C1 (MetaCons "NominalNewtype" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 StructuralInfo)))) (C1 (MetaCons "StructuralInfo" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [[StructuralInfo]]))))))
type SemanticVersion StructuralInfo # |
type SemanticVersion StructuralInfo = 0

# Serialisation

taggedEncode :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => a -> ByteString #

Tagged version of `encode`

taggedDecode :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => ByteString -> a #

Tagged version of `decode`

taggedDecodeOrFail :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => ByteString -> Either (ByteString, ByteOffset, String) (ByteString, ByteOffset, a) #

Tagged version of `decodeOrFail`

# IO functions for serialisation

taggedEncodeFile :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => FilePath -> a -> IO () #

Tagged version of `encodeFile`

taggedDecodeFile :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => FilePath -> IO a #

Tagged version of `decodeFile`

taggedDecodeFileOrFail :: forall a. (HasStructuralInfo a, HasSemanticVersion a, Binary a) => FilePath -> IO (Either (ByteOffset, String) a) #

Tagged version of `decodeFileOrFail`

# Class

class HasStructuralInfo a where #

Type class providing `StructuralInfo` for each data type.

For regular non-recursive ADTs `HasStructuralInfo` can be derived generically.

    data Record = Record { a :: Int, b :: Bool, c :: [Char] } deriving (Generic)
    instance hasStructuralInfo Record

For stable types, you can provide only type name

    instance HasStructuralInfo Int where structuralInfo = ghcNominalType -- infer name from Generic information
    instance HasStructuralInfo Integer where structuralInfo _ = NominalType "Integer"

Recursive type story is a bit sad atm. If the type structure is stable, you can do:

    instance HasStructuralInfo a => HasStructuralInfo [a] where structuralInfo = ghcStructuralInfo1

Methods

structuralInfo :: Proxy a -> StructuralInfo #

structuralInfo :: (Generic a, All2 HasStructuralInfo (GCode a), GDatatypeInfo a, SListI2 (GCode a)) => Proxy a -> StructuralInfo #

Instances

HasStructuralInfo Bool # |
Methods structuralInfo :: Proxy * Bool -> StructuralInfo #
HasStructuralInfo Char # |
Methods structuralInfo :: Proxy * Char -> StructuralInfo #
HasStructuralInfo Double # | Since binary-tagged-0.1.3.0
Methods structuralInfo :: Proxy * Double -> StructuralInfo #
HasStructuralInfo Float # | Since binary-tagged-0.1.3.0
Methods structuralInfo :: Proxy * Float -> StructuralInfo #
HasStructuralInfo Int # |
Methods structuralInfo :: Proxy * Int -> StructuralInfo #
HasStructuralInfo Int8 # |
Methods structuralInfo :: Proxy * Int8 -> StructuralInfo #
HasStructuralInfo Int16 # |
Methods structuralInfo :: Proxy * Int16 -> StructuralInfo #
HasStructuralInfo Int32 # |
Methods structuralInfo :: Proxy * Int32 -> StructuralInfo #
HasStructuralInfo Int64 # |
Methods structuralInfo :: Proxy * Int64 -> StructuralInfo #
HasStructuralInfo Integer # |
Methods structuralInfo :: Proxy * Integer -> StructuralInfo #
HasStructuralInfo Ordering # | Since binary-tagged-0.1.3.0
Methods structuralInfo :: Proxy * Ordering -> StructuralInfo #
HasStructuralInfo Word # |
Methods structuralInfo :: Proxy * Word -> StructuralInfo #
HasStructuralInfo Word8 # |
Methods structuralInfo :: Proxy * Word8 -> StructuralInfo #
HasStructuralInfo Word16 # |
Methods structuralInfo :: Proxy * Word16 -> StructuralInfo #
HasStructuralInfo Word32 # |
Methods structuralInfo :: Proxy * Word32 -> StructuralInfo #
HasStructuralInfo Word64 # |
Methods structuralInfo :: Proxy * Word64 -> StructuralInfo #
HasStructuralInfo () # | Since binary-tagged-0.1.3.0
Methods structuralInfo :: Proxy * () -> StructuralInfo #
HasStructuralInfo ByteString # |
Methods structuralInfo :: Proxy * ByteString -> StructuralInfo #
HasStructuralInfo ByteString # |
Methods structuralInfo :: Proxy * ByteString -> StructuralInfo #
HasStructuralInfo Text # |
Methods structuralInfo :: Proxy * Text -> StructuralInfo #
HasStructuralInfo UTCTime # |
Methods structuralInfo :: Proxy * UTCTime -> StructuralInfo #
HasStructuralInfo Value # |
Methods structuralInfo :: Proxy * Value -> StructuralInfo #
HasStructuralInfo Text # |
Methods structuralInfo :: Proxy * Text -> StructuralInfo #
HasStructuralInfo Natural # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * Natural -> StructuralInfo #
HasStructuralInfo E0 # |
Methods structuralInfo :: Proxy * E0 -> StructuralInfo #
HasStructuralInfo E1 # |
Methods structuralInfo :: Proxy * E1 -> StructuralInfo #
HasStructuralInfo E2 # |
Methods structuralInfo :: Proxy * E2 -> StructuralInfo #
HasStructuralInfo E3 # |
Methods structuralInfo :: Proxy * E3 -> StructuralInfo #
HasStructuralInfo E6 # |
Methods structuralInfo :: Proxy * E6 -> StructuralInfo #
HasStructuralInfo E9 # |
Methods structuralInfo :: Proxy * E9 -> StructuralInfo #
HasStructuralInfo E12 # |
Methods structuralInfo :: Proxy * E12 -> StructuralInfo #
HasStructuralInfo Version # | Since binary-tagged-0.1.3.0
Methods structuralInfo :: Proxy * Version -> StructuralInfo #
HasStructuralInfo All # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * All -> StructuralInfo #
HasStructuralInfo Any # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * Any -> StructuralInfo #
HasStructuralInfo IntSet # |
Methods structuralInfo :: Proxy * IntSet -> StructuralInfo #
HasStructuralInfo LocalTime # |
Methods structuralInfo :: Proxy * LocalTime -> StructuralInfo #
HasStructuralInfo TimeOfDay # |
Methods structuralInfo :: Proxy * TimeOfDay -> StructuralInfo #
HasStructuralInfo TimeZone # |
Methods structuralInfo :: Proxy * TimeZone -> StructuralInfo #
HasStructuralInfo NominalDiffTime # |
Methods structuralInfo :: Proxy * NominalDiffTime -> StructuralInfo #
HasStructuralInfo Day # |
Methods structuralInfo :: Proxy * Day -> StructuralInfo #
HasStructuralInfo UniversalTime # |
Methods structuralInfo :: Proxy * UniversalTime -> StructuralInfo #
HasStructuralInfo DiffTime # |
Methods structuralInfo :: Proxy * DiffTime -> StructuralInfo #
HasStructuralInfo StructuralInfo # |
Methods structuralInfo :: Proxy * StructuralInfo -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo [a] # |
Methods structuralInfo :: Proxy * [a] -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Maybe a) # |
Methods structuralInfo :: Proxy * (Maybe a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Ratio a) # |
Methods structuralInfo :: Proxy * (Ratio a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Min a) # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * (Min a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Max a) # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * (Max a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (First a) # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * (First a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Last a) # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * (Last a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (WrappedMonoid a) # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * (WrappedMonoid a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Option a) # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * (Option a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (NonEmpty a) # |
Methods structuralInfo :: Proxy * (NonEmpty a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Fixed a) # | Since binary-tagged-0.1.3.0
Methods structuralInfo :: Proxy * (Fixed a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Dual a) # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * (Dual a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Sum a) # |
Methods structuralInfo :: Proxy * (Sum a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Product a) # |
Methods structuralInfo :: Proxy * (Product a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (First a) # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * (First a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Last a) # | Since binary-tagged-0.1.4.0
Methods structuralInfo :: Proxy * (Last a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Seq a) # |
Methods structuralInfo :: Proxy * (Seq a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (IntMap a) # |
Methods structuralInfo :: Proxy * (IntMap a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Set a) # |
Methods structuralInfo :: Proxy * (Set a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (HashSet a) # |
Methods structuralInfo :: Proxy * (HashSet a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Vector a) # |
Methods structuralInfo :: Proxy * (Vector a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Vector a) # |
Methods structuralInfo :: Proxy * (Vector a) -> StructuralInfo #
HasStructuralInfo a => HasStructuralInfo (Vector a) # |
Methods structuralInfo :: Proxy * (Vector a) -> StructuralInfo #
(HasStructuralInfo a, HasStructuralInfo b) => HasStructuralInfo (Either a b) # |
Methods structuralInfo :: Proxy * (Either a b) -> StructuralInfo #
(HasStructuralInfo a, HasStructuralInfo b) => HasStructuralInfo (a, b) # |
Methods structuralInfo :: Proxy * (a, b) -> StructuralInfo #
(HasStructuralInfo k, HasStructuralInfo v) => HasStructuralInfo (HashMap k v) # |
Methods structuralInfo :: Proxy * (HashMap k v) -> StructuralInfo #
(HasStructuralInfo k, HasStructuralInfo v) => HasStructuralInfo (Map k v) # |
Methods structuralInfo :: Proxy * (Map k v) -> StructuralInfo #
(HasStructuralInfo i, HasStructuralInfo e) => HasStructuralInfo (UArray i e) # |
Methods structuralInfo :: Proxy * (UArray i e) -> StructuralInfo #
(HasStructuralInfo i, HasStructuralInfo e) => HasStructuralInfo (Array i e) # |
Methods structuralInfo :: Proxy * (Array i e) -> StructuralInfo #
(HasStructuralInfo a, HasStructuralInfo b, HasStructuralInfo c) => HasStructuralInfo (a, b, c) # |
Methods structuralInfo :: Proxy * (a, b, c) -> StructuralInfo #
(HasStructuralInfo a, HasStructuralInfo b, HasStructuralInfo c, HasStructuralInfo d) => HasStructuralInfo (a, b, c, d) # |
Methods structuralInfo :: Proxy * (a, b, c, d) -> StructuralInfo #

class KnownNat (SemanticVersion a) => HasSemanticVersion a #

A helper type family for `encodeTaggedFile` and `decodeTaggedFile`.

The default definition is ``SemanticVersion` a = 0`

Associated Types

type SemanticVersion a :: Nat #

Instances

HasSemanticVersion Bool # |
Associated Types type SemanticVersion Bool :: Nat #
HasSemanticVersion Char # |
Associated Types type SemanticVersion Char :: Nat #
HasSemanticVersion Double # | Since binary-tagged-0.1.3.0
Associated Types type SemanticVersion Double :: Nat #
HasSemanticVersion Float # | Since binary-tagged-0.1.3.0
Associated Types type SemanticVersion Float :: Nat #
HasSemanticVersion Int # |
Associated Types type SemanticVersion Int :: Nat #
HasSemanticVersion Int8 # |
Associated Types type SemanticVersion Int8 :: Nat #
HasSemanticVersion Int16 # |
Associated Types type SemanticVersion Int16 :: Nat #
HasSemanticVersion Int32 # |
Associated Types type SemanticVersion Int32 :: Nat #
HasSemanticVersion Int64 # |
Associated Types type SemanticVersion Int64 :: Nat #
HasSemanticVersion Integer # |
Associated Types type SemanticVersion Integer :: Nat #
HasSemanticVersion Ordering # | Since binary-tagged-0.1.3.0
Associated Types type SemanticVersion Ordering :: Nat #
HasSemanticVersion Word # |
Associated Types type SemanticVersion Word :: Nat #
HasSemanticVersion Word8 # |
Associated Types type SemanticVersion Word8 :: Nat #
HasSemanticVersion Word16 # |
Associated Types type SemanticVersion Word16 :: Nat #
HasSemanticVersion Word32 # |
Associated Types type SemanticVersion Word32 :: Nat #
HasSemanticVersion Word64 # |
Associated Types type SemanticVersion Word64 :: Nat #
HasSemanticVersion () # | Since binary-tagged-0.1.3.0
Associated Types type SemanticVersion () :: Nat #
HasSemanticVersion ByteString # |
Associated Types type SemanticVersion ByteString :: Nat #
HasSemanticVersion ByteString # |
Associated Types type SemanticVersion ByteString :: Nat #
HasSemanticVersion Text # |
Associated Types type SemanticVersion Text :: Nat #
HasSemanticVersion UTCTime # |
Associated Types type SemanticVersion UTCTime :: Nat #
HasSemanticVersion Value # |
Associated Types type SemanticVersion Value :: Nat #
HasSemanticVersion Text # |
Associated Types type SemanticVersion Text :: Nat #
HasSemanticVersion Natural # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion Natural :: Nat #
HasSemanticVersion Version # | Since binary-tagged-0.1.3.0
Associated Types type SemanticVersion Version :: Nat #
HasSemanticVersion All # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion All :: Nat #
HasSemanticVersion Any # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion Any :: Nat #
HasSemanticVersion IntSet # |
Associated Types type SemanticVersion IntSet :: Nat #
HasSemanticVersion LocalTime # |
Associated Types type SemanticVersion LocalTime :: Nat #
HasSemanticVersion TimeOfDay # |
Associated Types type SemanticVersion TimeOfDay :: Nat #
HasSemanticVersion TimeZone # |
Associated Types type SemanticVersion TimeZone :: Nat #
HasSemanticVersion NominalDiffTime # |
Associated Types type SemanticVersion NominalDiffTime :: Nat #
HasSemanticVersion Day # |
Associated Types type SemanticVersion Day :: Nat #
HasSemanticVersion UniversalTime # |
Associated Types type SemanticVersion UniversalTime :: Nat #
HasSemanticVersion DiffTime # |
Associated Types type SemanticVersion DiffTime :: Nat #
HasSemanticVersion StructuralInfo # |
Associated Types type SemanticVersion StructuralInfo :: Nat #
HasSemanticVersion a => HasSemanticVersion [a] # |
Associated Types type SemanticVersion [a] :: Nat #
HasSemanticVersion a => HasSemanticVersion (Maybe a) # |
Associated Types type SemanticVersion (Maybe a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Ratio a) # |
Associated Types type SemanticVersion (Ratio a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Min a) # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion (Min a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Max a) # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion (Max a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (First a) # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion (First a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Last a) # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion (Last a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (WrappedMonoid a) # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion (WrappedMonoid a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Option a) # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion (Option a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (NonEmpty a) # |
Associated Types type SemanticVersion (NonEmpty a) :: Nat #
HasSemanticVersion (Fixed a) # | Since binary-tagged-0.1.3.0
Associated Types type SemanticVersion (Fixed a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Dual a) # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion (Dual a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Sum a) # |
Associated Types type SemanticVersion (Sum a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Product a) # |
Associated Types type SemanticVersion (Product a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (First a) # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion (First a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Last a) # | Since binary-tagged-0.1.4.0
Associated Types type SemanticVersion (Last a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Seq a) # |
Associated Types type SemanticVersion (Seq a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (IntMap a) # |
Associated Types type SemanticVersion (IntMap a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Set a) # |
Associated Types type SemanticVersion (Set a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (HashSet a) # |
Associated Types type SemanticVersion (HashSet a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Vector a) # |
Associated Types type SemanticVersion (Vector a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Vector a) # |
Associated Types type SemanticVersion (Vector a) :: Nat #
HasSemanticVersion a => HasSemanticVersion (Vector a) # |
Associated Types type SemanticVersion (Vector a) :: Nat #
(HasSemanticVersion a, HasSemanticVersion b, KnownNat (SemanticVersion (Either a b))) => HasSemanticVersion (Either a b) # |
Associated Types type SemanticVersion (Either a b) :: Nat #
(HasSemanticVersion a, HasSemanticVersion b, KnownNat (SemanticVersion (a, b))) => HasSemanticVersion (a, b) # |
Associated Types type SemanticVersion (a, b) :: Nat #
(HasSemanticVersion k, HasSemanticVersion v, KnownNat (SemanticVersion (HashMap k v))) => HasSemanticVersion (HashMap k v) # |
Associated Types type SemanticVersion (HashMap k v) :: Nat #
(HasSemanticVersion k, HasSemanticVersion v, KnownNat (SemanticVersion (Map k v))) => HasSemanticVersion (Map k v) # |
Associated Types type SemanticVersion (Map k v) :: Nat #
(HasSemanticVersion i, HasSemanticVersion e, KnownNat (SemanticVersion (UArray i e))) => HasSemanticVersion (UArray i e) # |
Associated Types type SemanticVersion (UArray i e) :: Nat #
(HasSemanticVersion i, HasSemanticVersion e, KnownNat (SemanticVersion (Array i e))) => HasSemanticVersion (Array i e) # |
Associated Types type SemanticVersion (Array i e) :: Nat #
(HasSemanticVersion a, HasSemanticVersion b, HasSemanticVersion c, KnownNat (SemanticVersion (a, b, c))) => HasSemanticVersion (a, b, c) # | Since binary-tagged-0.1.3.0
Associated Types type SemanticVersion (a, b, c) :: Nat #
(HasSemanticVersion a, HasSemanticVersion b, HasSemanticVersion c, HasSemanticVersion d, KnownNat (SemanticVersion (a, b, c, d))) => HasSemanticVersion (a, b, c, d) # | Since binary-tagged-0.1.3.0
Associated Types type SemanticVersion (a, b, c, d) :: Nat #

type Version = Word32 #

Type the semantic version is serialised with.

## Type level calculations

type Interleave n m = SumUpTo (n + m) + m #

Interleaving

    3 | 9  .  .  .  .
    2 | 5  8  .  .  .
    1 | 2  4  7 11  .
    0 | 0  1  3  6 10
    -----------------
        0  1  2  3  4

This can be calculated by `f x y = sum ([0..x+y]) + y`

type SumUpTo n = Div2 (n * (n + 1)) #

type family Div2 (n :: Nat) :: Nat where ... #

Equations

Div2 0 = 0 |
Div2 1 = 0 |
Div2 n = 1 + Div2 (n - 2) |

# Generic derivation

## GHC

ghcStructuralInfo :: (Generic a, All2 HasStructuralInfo (GCode a), GDatatypeInfo a, SListI2 (GCode a)) => Proxy a -> StructuralInfo #

ghcNominalType :: (Generic a, GDatatypeInfo a) => Proxy a -> StructuralInfo #

ghcStructuralInfo1 :: forall f a. (Generic1 f, GDatatypeInfo (f a), HasStructuralInfo a) => Proxy (f a) -> StructuralInfo #

## SOP

sopStructuralInfo :: forall a. (Generic a, HasDatatypeInfo a, All2 HasStructuralInfo (Code a)) => Proxy a -> StructuralInfo #

sopNominalType :: forall a. (Generic a, HasDatatypeInfo a) => Proxy a -> StructuralInfo #

sopStructuralInfo1 :: forall f a. (Generic (f a), HasDatatypeInfo (f a), HasStructuralInfo a) => Proxy (f a) -> StructuralInfo #

## SOP direct

sopStructuralInfoS :: forall xss. (All2 HasStructuralInfo xss, SListI2 xss) => DatatypeInfo xss -> StructuralInfo #

sopNominalTypeS :: DatatypeInfo xss -> StructuralInfo #

sopStructuralInfo1S :: StructuralInfo -> DatatypeInfo xss -> StructuralInfo #

# Hash

structuralInfoSha1Digest :: StructuralInfo -> Digest SHA1State #

structuralInfoSha1ByteStringDigest :: StructuralInfo -> ByteString #