lorentz-0.13.0: EDSL for the Michelson Language
Safe HaskellNone
LanguageHaskell2010

Lorentz.Bytes

Description

Type-safe operations with bytes-like data.

Synopsis

Documentation

class (KnownValue bs, ToT bs ~ ToT ByteString) => BytesLike bs where Source #

Everything which is represented as bytes inside.

Methods

toBytes :: bs -> ByteString Source #

Instances

Instances details
BytesLike ByteString Source # 
Instance details

Defined in Lorentz.Bytes

Typeable a => BytesLike (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

(Typeable alg, Typeable a) => BytesLike (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

toBytes :: Hash alg a -> ByteString Source #

newtype Packed a Source #

Represents a ByteString resulting from packing a value of type a.

This is not guaranteed to keep some packed value, and unpack can fail. We do so because often we need to accept values of such type from user, and also because there is no simple way to check validity of packed data without performing full unpack. So this wrapper is rather a hint for users.

Constructors

Packed 

Fields

Instances

Instances details
Eq (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

(==) :: Packed a -> Packed a -> Bool #

(/=) :: Packed a -> Packed a -> Bool #

Ord (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

compare :: Packed a -> Packed a -> Ordering #

(<) :: Packed a -> Packed a -> Bool #

(<=) :: Packed a -> Packed a -> Bool #

(>) :: Packed a -> Packed a -> Bool #

(>=) :: Packed a -> Packed a -> Bool #

max :: Packed a -> Packed a -> Packed a #

min :: Packed a -> Packed a -> Packed a #

Show (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

showsPrec :: Int -> Packed a -> ShowS #

show :: Packed a -> String #

showList :: [Packed a] -> ShowS #

Generic (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type Rep (Packed a) :: Type -> Type #

Methods

from :: Packed a -> Rep (Packed a) x #

to :: Rep (Packed a) x -> Packed a #

Buildable (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

build :: Packed a -> Builder #

TypeHasDoc a => TypeHasDoc (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type TypeDocFieldDescriptions (Packed a) :: FieldDescriptions #

IsoValue (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type ToT (Packed a) :: T #

Methods

toVal :: Packed a -> Value (ToT (Packed a)) #

fromVal :: Value (ToT (Packed a)) -> Packed a #

HasAnnotation (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Typeable a => BytesLike (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

CanCastTo (Packed a :: Type) ByteString Source # 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (Packed a) -> Proxy ByteString -> () Source #

CanCastTo a b => CanCastTo (Packed a :: Type) (Packed b :: Type) Source # 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (Packed a) -> Proxy (Packed b) -> () Source #

type Rep (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

type Rep (Packed a) = D1 ('MetaData "Packed" "Lorentz.Bytes" "lorentz-0.13.0-inplace" 'True) (C1 ('MetaCons "Packed" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPacked") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))
type TypeDocFieldDescriptions (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

type ToT (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

newtype TSignature a Source #

Represents a signature, where signed data has given type.

Since we usually sign a packed data, a common pattern for this type is TSignature (Packed signedData). If you don't want to use Packed, use plain TSignature ByteString instead.

Constructors

TSignature 

Instances

Instances details
Show (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

Generic (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type Rep (TSignature a) :: Type -> Type #

Methods

from :: TSignature a -> Rep (TSignature a) x #

to :: Rep (TSignature a) x -> TSignature a #

Buildable (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

build :: TSignature a -> Builder #

TypeHasDoc a => TypeHasDoc (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type TypeDocFieldDescriptions (TSignature a) :: FieldDescriptions #

IsoValue (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type ToT (TSignature a) :: T #

HasAnnotation (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

CanCastTo (TSignature a :: Type) ByteString Source # 
Instance details

Defined in Lorentz.Coercions

CanCastTo a b => CanCastTo (TSignature a :: Type) (TSignature b :: Type) Source # 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (TSignature a) -> Proxy (TSignature b) -> () Source #

type Rep (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

type Rep (TSignature a) = D1 ('MetaData "TSignature" "Lorentz.Bytes" "lorentz-0.13.0-inplace" 'True) (C1 ('MetaCons "TSignature" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTSignature") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Signature)))
type TypeDocFieldDescriptions (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

type ToT (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

lSign :: (MonadRandom m, BytesLike a) => SecretKey -> a -> m (TSignature a) Source #

Sign data using SecretKey

newtype Hash (alg :: HashAlgorithmKind) a Source #

Hash of type t evaluated from data of type a.

Constructors

UnsafeHash 

Fields

Instances

Instances details
CanCastTo (Hash alg a :: Type) ByteString Source # 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (Hash alg a) -> Proxy ByteString -> () Source #

(CanCastTo alg1 alg2, CanCastTo a1 a2) => CanCastTo (Hash alg1 a1 :: Type) (Hash alg2 a2 :: Type) Source # 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (Hash alg1 a1) -> Proxy (Hash alg2 a2) -> () Source #

Eq (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

(==) :: Hash alg a -> Hash alg a -> Bool #

(/=) :: Hash alg a -> Hash alg a -> Bool #

Ord (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

compare :: Hash alg a -> Hash alg a -> Ordering #

(<) :: Hash alg a -> Hash alg a -> Bool #

(<=) :: Hash alg a -> Hash alg a -> Bool #

(>) :: Hash alg a -> Hash alg a -> Bool #

(>=) :: Hash alg a -> Hash alg a -> Bool #

max :: Hash alg a -> Hash alg a -> Hash alg a #

min :: Hash alg a -> Hash alg a -> Hash alg a #

Show (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

showsPrec :: Int -> Hash alg a -> ShowS #

show :: Hash alg a -> String #

showList :: [Hash alg a] -> ShowS #

Generic (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type Rep (Hash alg a) :: Type -> Type #

Methods

from :: Hash alg a -> Rep (Hash alg a) x #

to :: Rep (Hash alg a) x -> Hash alg a #

Buildable (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

build :: Hash alg a -> Builder #

(KnownHashAlgorithm alg, TypeHasDoc a) => TypeHasDoc (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type TypeDocFieldDescriptions (Hash alg a) :: FieldDescriptions #

Methods

typeDocName :: Proxy (Hash alg a) -> Text #

typeDocMdDescription :: Markdown #

typeDocMdReference :: Proxy (Hash alg a) -> WithinParens -> Markdown #

typeDocDependencies :: Proxy (Hash alg a) -> [SomeDocDefinitionItem] #

typeDocHaskellRep :: TypeDocHaskellRep (Hash alg a) #

typeDocMichelsonRep :: TypeDocMichelsonRep (Hash alg a) #

IsoValue (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type ToT (Hash alg a) :: T #

Methods

toVal :: Hash alg a -> Value (ToT (Hash alg a)) #

fromVal :: Value (ToT (Hash alg a)) -> Hash alg a #

HasAnnotation (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

(Typeable alg, Typeable a) => BytesLike (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

toBytes :: Hash alg a -> ByteString Source #

type Rep (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

type Rep (Hash alg a) = D1 ('MetaData "Hash" "Lorentz.Bytes" "lorentz-0.13.0-inplace" 'True) (C1 ('MetaCons "UnsafeHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "unHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))
type TypeDocFieldDescriptions (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

type TypeDocFieldDescriptions (Hash alg a) = '[] :: [(Symbol, (Maybe Symbol, [(Symbol, Symbol)]))]
type ToT (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

type ToT (Hash alg a) = ToT ByteString

data DHashAlgorithm Source #

Documentation item for hash algorithms.

Instances

Instances details
Eq DHashAlgorithm Source # 
Instance details

Defined in Lorentz.Bytes

Ord DHashAlgorithm Source # 
Instance details

Defined in Lorentz.Bytes

DocItem DHashAlgorithm Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type DocItemPlacement DHashAlgorithm :: DocItemPlacementKind #

type DocItemReferenced DHashAlgorithm :: DocItemReferencedKind #

type DocItemPlacement DHashAlgorithm Source # 
Instance details

Defined in Lorentz.Bytes

type DocItemReferenced DHashAlgorithm Source # 
Instance details

Defined in Lorentz.Bytes

class Typeable alg => KnownHashAlgorithm (alg :: HashAlgorithmKind) where Source #

Hash algorithm used in Tezos.

Minimal complete definition

computeHash, toHash

Methods

hashAlgorithmName :: Proxy alg -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: BytesLike bs => (bs ': s) :-> (Hash alg bs ': s) Source #

Instances

Instances details
KnownHashAlgorithm Keccak Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Keccak -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Keccak bs ': s) Source #

KnownHashAlgorithm Sha3 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha3 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha3 bs ': s) Source #

KnownHashAlgorithm Blake2b Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Blake2b -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Blake2b bs ': s) Source #

KnownHashAlgorithm Sha512 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha512 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha512 bs ': s) Source #

KnownHashAlgorithm Sha256 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha256 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha256 bs ': s) Source #

toHashHs :: forall alg bs. (BytesLike bs, KnownHashAlgorithm alg) => bs -> Hash alg bs Source #

Evaluate hash in Haskell world.

data Sha256 :: HashAlgorithmKind Source #

Instances

Instances details
KnownHashAlgorithm Sha256 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha256 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha256 bs ': s) Source #

data Sha512 :: HashAlgorithmKind Source #

Instances

Instances details
KnownHashAlgorithm Sha512 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha512 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha512 bs ': s) Source #

data Blake2b :: HashAlgorithmKind Source #

Instances

Instances details
KnownHashAlgorithm Blake2b Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Blake2b -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Blake2b bs ': s) Source #

data Sha3 :: HashAlgorithmKind Source #

Instances

Instances details
KnownHashAlgorithm Sha3 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha3 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha3 bs ': s) Source #

data Keccak :: HashAlgorithmKind Source #

Instances

Instances details
KnownHashAlgorithm Keccak Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Keccak -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Keccak bs ': s) Source #