morley-upgradeable-0.3: Upgradeability infrastructure based on Morley.
Safe HaskellNone
LanguageHaskell2010

Lorentz.UStore.Instr

Description

Instructions to work with UStore.

Synopsis

Documentation

unsafeEmptyUStore :: forall store s. s :-> (UStore store ': s) Source #

Put an empty UStore onto the stack. This function is generally unsafe: if store template contains a UStoreField, the resulting UStore is not immediately usable. If you are sure that UStore contains only submaps, feel free to just use the result of this function. Otherwise you must set all fields.

ustoreMem :: forall store name s. KeyAccessC store name => Label name -> (GetUStoreKey store name ': (UStore store ': s)) :-> (Bool ': s) Source #

ustoreGet :: forall store name s. (KeyAccessC store name, ValueAccessC store name) => Label name -> (GetUStoreKey store name ': (UStore store ': s)) :-> (Maybe (GetUStoreValue store name) ': s) Source #

ustoreUpdate :: forall store name s. (KeyAccessC store name, ValueAccessC store name) => Label name -> (GetUStoreKey store name ': (Maybe (GetUStoreValue store name) ': (UStore store ': s))) :-> (UStore store ': s) Source #

ustoreInsert :: forall store name s. (KeyAccessC store name, ValueAccessC store name) => Label name -> (GetUStoreKey store name ': (GetUStoreValue store name ': (UStore store ': s))) :-> (UStore store ': s) Source #

ustoreInsertNew :: forall store name s. (KeyAccessC store name, ValueAccessC store name) => Label name -> (forall s0 any. (GetUStoreKey store name ': s0) :-> any) -> (GetUStoreKey store name ': (GetUStoreValue store name ': (UStore store ': s))) :-> (UStore store ': s) Source #

Insert a key-value pair, but fail if it will overwrite some existing entry.

ustoreDelete :: forall store name s. KeyAccessC store name => Label name -> (GetUStoreKey store name ': (UStore store ': s)) :-> (UStore store ': s) Source #

ustoreToField :: forall store name s. FieldAccessC store name => Label name -> (UStore store ': s) :-> (GetUStoreField store name ': s) Source #

Like toField, but for UStore.

This may fail only if UStore was made up incorrectly during contract initialization.

ustoreGetField :: forall store name s. FieldAccessC store name => Label name -> (UStore store ': s) :-> (GetUStoreField store name ': (UStore store ': s)) Source #

Like getField, but for UStore.

This may fail only if UStore was made up incorrectly during contract initialization.

ustoreSetField :: forall store name s. FieldAccessC store name => Label name -> (GetUStoreField store name ': (UStore store ': s)) :-> (UStore store ': s) Source #

Like setField, but for UStore.

ustoreRemoveFieldUnsafe :: forall store name s. FieldAccessC store name => Label name -> (UStore store ': s) :-> (UStore store ': s) Source #

Remove a field from UStore, for internal purposes only.

Instruction constraints

type HasUStore name key value store = (KeyAccessC store name, ValueAccessC store name, GetUStoreKey store name ~ key, GetUStoreValue store name ~ value) Source #

This constraint can be used if a function needs to work with big store, but needs to know only about some submap(s) of it.

It can use all UStore operations for a particular name, key and value without knowing whole template.

type HasUField name ty store = (FieldAccessC store name, GetUStoreField store name ~ ty) Source #

This constraint can be used if a function needs to work with big store, but needs to know only about some field of it.

type HasUStoreForAllIn store constrained = (Generic store, GHasStoreForAllIn constrained (Rep store)) Source #

Write down all sensisble constraints which given store satisfies and apply them to constrained.

This store should have |~> and UStoreField fields in its immediate fields, no deep inspection is performed.

Internals

packSubMapUKey :: forall (field :: Symbol) k s. (KnownSymbol field, NicePackedValue k) => (k ': s) :-> (ByteString ': s) Source #