store-0.7.20: Fast binary serialization

Safe Haskell | None
Language | Haskell2010

Data.Store.TypeHash

Contents

- TH for generating HasTypeHash instances

Description

This module provides utilities for computing hashes based on the structural definitions of datatypes. The purpose of this is to provide a mechanism for tagging serialized data in such a way that deserialization issues can be anticipated.

Synopsis

- newtype Tagged a = Tagged {
  - unTagged :: a
  }
- data TypeHash
- class HasTypeHash a where
  - typeHash :: Proxy a -> TypeHash
- mkHasTypeHash :: Type -> Q [Dec]
- mkManyHasTypeHash :: [Q Type] -> Q [Dec]

# Documentation

newtype Tagged a Source #

Constructors

Tagged |

Fields

- unTagged :: a

#### Instances

Instances details

NFData a => NFData (Tagged a) Source # |
Instance details Defined in Data.Store.TypeHash.Internal Methods rnf :: Tagged a -> () Source #
Data a => Data (Tagged a) Source # |

Instance details

Defined in Data.Store.TypeHash.Internal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Tagged a -> c (Tagged a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Tagged a) Source #

toConstr :: Tagged a -> Constr Source #

dataTypeOf :: Tagged a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Tagged a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tagged a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Tagged a -> Tagged a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tagged a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tagged a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Tagged a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Tagged a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tagged a -> m (Tagged a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged a -> m (Tagged a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged a -> m (Tagged a) Source #

Generic (Tagged a) Source # |

Instance details

Defined in Data.Store.TypeHash.Internal

Associated Types

type Rep (Tagged a) |
Instance details Defined in Data.Store.TypeHash.Internal type Rep (Tagged a) = D1 ('MetaData "Tagged" "Data.Store.TypeHash.Internal" "store-0.7.20-9ePWelnBqsfACPE7fnE1Lj" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

from :: Tagged a -> Rep (Tagged a) x Source #

to :: Rep (Tagged a) x -> Tagged a Source #

Show a => Show (Tagged a) Source # |
Instance details Defined in Data.Store.TypeHash.Internal Methods showsPrec :: Int -> Tagged a -> ShowS Source # show :: Tagged a -> String Source # showList :: [Tagged a] -> ShowS Source #
Eq a => Eq (Tagged a) Source # |
Instance details Defined in Data.Store.TypeHash.Internal Methods (==) :: Tagged a -> Tagged a -> Bool Source # (/=) :: Tagged a -> Tagged a -> Bool Source #
Ord a => Ord (Tagged a) Source # |
Instance details Defined in Data.Store.TypeHash.Internal Methods compare :: Tagged a -> Tagged a -> Ordering Source # (<) :: Tagged a -> Tagged a -> Bool Source # (<=) :: Tagged a -> Tagged a -> Bool Source # (>) :: Tagged a -> Tagged a -> Bool Source # (>=) :: Tagged a -> Tagged a -> Bool Source # max :: Tagged a -> Tagged a -> Tagged a Source # min :: Tagged a -> Tagged a -> Tagged a Source #
(Store a, HasTypeHash a) => Store (Tagged a) Source # |
Instance details Defined in Data.Store.TypeHash.Internal Methods size :: Size (Tagged a) Source # poke :: Tagged a -> Poke () Source # peek :: Peek (Tagged a) Source #
type Rep (Tagged a) Source # |
Instance details Defined in Data.Store.TypeHash.Internal type Rep (Tagged a) = D1 ('MetaData "Tagged" "Data.Store.TypeHash.Internal" "store-0.7.20-9ePWelnBqsfACPE7fnE1Lj" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

data TypeHash Source #

#### Instances

Instances details

NFData TypeHash Source # |
Instance details Defined in Data.Store.TypeHash.Internal Methods rnf :: TypeHash -> () Source #
Data TypeHash Source # |

Instance details

Defined in Data.Store.TypeHash.Internal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypeHash -> c TypeHash Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TypeHash Source #

toConstr :: TypeHash -> Constr Source #

dataTypeOf :: TypeHash -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TypeHash) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TypeHash) Source #

gmapT :: (forall b. Data b => b -> b) -> TypeHash -> TypeHash Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypeHash -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypeHash -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TypeHash -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TypeHash -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypeHash -> m TypeHash Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeHash -> m TypeHash Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeHash -> m TypeHash Source #

Generic TypeHash Source # |

Instance details

Defined in Data.Store.TypeHash.Internal

Associated Types

type Rep TypeHash |
Instance details Defined in Data.Store.TypeHash.Internal type Rep TypeHash = D1 ('MetaData "TypeHash" "Data.Store.TypeHash.Internal" "store-0.7.20-9ePWelnBqsfACPE7fnE1Lj" 'True) (C1 ('MetaCons "TypeHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTypeHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (StaticSize 20 ByteString))))

Methods

from :: TypeHash -> Rep TypeHash x Source #

to :: Rep TypeHash x -> TypeHash Source #

Show TypeHash Source # |
Instance details Defined in Data.Store.TypeHash.Internal Methods showsPrec :: Int -> TypeHash -> ShowS Source # show :: TypeHash -> String Source # showList :: [TypeHash] -> ShowS Source #
Eq TypeHash Source # |
Instance details Defined in Data.Store.TypeHash.Internal Methods (==) :: TypeHash -> TypeHash -> Bool Source # (/=) :: TypeHash -> TypeHash -> Bool Source #
Ord TypeHash Source # |
Instance details Defined in Data.Store.TypeHash.Internal Methods compare :: TypeHash -> TypeHash -> Ordering Source # (<) :: TypeHash -> TypeHash -> Bool Source # (<=) :: TypeHash -> TypeHash -> Bool Source # (>) :: TypeHash -> TypeHash -> Bool Source # (>=) :: TypeHash -> TypeHash -> Bool Source # max :: TypeHash -> TypeHash -> TypeHash Source # min :: TypeHash -> TypeHash -> TypeHash Source #
Store TypeHash Source # |
Instance details Defined in Data.Store.TypeHash.Internal Methods size :: Size TypeHash Source # poke :: TypeHash -> Poke () Source # peek :: Peek TypeHash Source #
Lift TypeHash Source # |
Instance details Defined in Data.Store.TypeHash.Internal Methods lift :: Quote m => TypeHash -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => TypeHash -> Code m TypeHash Source #
type Rep TypeHash Source # |
Instance details Defined in Data.Store.TypeHash.Internal type Rep TypeHash = D1 ('MetaData "TypeHash" "Data.Store.TypeHash.Internal" "store-0.7.20-9ePWelnBqsfACPE7fnE1Lj" 'True) (C1 ('MetaCons "TypeHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTypeHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (StaticSize 20 ByteString))))

class HasTypeHash a where Source #

Methods

typeHash :: Proxy a -> TypeHash Source #

# TH for generating HasTypeHash instances

mkHasTypeHash :: Type -> Q [Dec] Source #

Deprecated: Use of Data.Store.TypeHash isn't recommended, as the hashes are too unstable for most uses. Please instead consider using Data.Store.Version. See https://github.com/fpco/store/issues/53

mkManyHasTypeHash :: [Q Type] -> Q [Dec] Source #

Deprecated: Use of Data.Store.TypeHash isn't recommended, as the hashes are too unstable for most uses. Please instead consider using Data.Store.Version. See https://github.com/fpco/store/issues/53