| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Lorentz.ADT
Synopsis
- type HasField dt fname = (InstrGetFieldC dt fname, InstrSetFieldC dt fname)
- type HasFieldOfType dt fname fieldTy = (HasField dt fname, GetFieldType dt fname ~ fieldTy)
- type family HasFieldsOfType (dt :: Type) (fs :: [NamedField]) :: Constraint where ...
- data NamedField = NamedField Symbol Type
- type (:=) n ty = 'NamedField n ty
- class HasDupableGetters a
- toField :: forall dt name st. InstrGetFieldC dt name => Label name -> (dt : st) :-> (GetFieldType dt name : st)
- toFieldNamed :: forall dt name st. InstrGetFieldC dt name => Label name -> (dt : st) :-> ((name :! GetFieldType dt name) : st)
- getField :: forall dt name st. (InstrGetFieldC dt name, Dupable (GetFieldType dt name), HasDupableGetters dt) => Label name -> (dt : st) :-> (GetFieldType dt name : (dt ': st))
- getFieldNamed :: forall dt name st. (InstrGetFieldC dt name, Dupable (GetFieldType dt name), HasDupableGetters dt) => Label name -> (dt : st) :-> ((name :! GetFieldType dt name) : (dt ': st))
- setField :: forall dt name st. InstrSetFieldC dt name => Label name -> (GetFieldType dt name ': (dt ': st)) :-> (dt ': st)
- modifyField :: forall dt name st. (InstrGetFieldC dt name, InstrSetFieldC dt name, Dupable (GetFieldType dt name), HasDupableGetters dt) => Label name -> (forall st0. (GetFieldType dt name ': st0) :-> (GetFieldType dt name ': st0)) -> (dt : st) :-> (dt : st)
- construct :: forall dt st. (InstrConstructC dt, RMap (ConstructorFieldTypes dt)) => Rec (FieldConstructor st) (ConstructorFieldTypes dt) -> st :-> (dt : st)
- constructT :: forall dt fctors st. (InstrConstructC dt, RMap (ConstructorFieldTypes dt), fctors ~ Rec (FieldConstructor st) (ConstructorFieldTypes dt), RecFromTuple fctors) => IsoRecTuple fctors -> st :-> (dt : st)
- constructStack :: forall dt fields st. (InstrConstructC dt, fields ~ ConstructorFieldTypes dt, (ToTs fields ++ ToTs st) ~ ToTs (fields ++ st)) => (fields ++ st) :-> (dt : st)
- deconstruct :: forall dt fields st. (InstrDeconstructC dt (ToTs st), fields ~ GFieldTypes (GRep dt) '[], (ToTs fields ++ ToTs st) ~ ToTs (fields ++ st)) => (dt : st) :-> (fields ++ st)
- fieldCtor :: HasCallStack => (st :-> (f : st)) -> FieldConstructor st f
- wrap_ :: forall dt name st. InstrWrapC dt name => Label name -> AppendCtorField (GetCtorField dt name) st :-> (dt : st)
- wrapOne :: forall dt name st. InstrWrapOneC dt name => Label name -> (CtorOnlyField name dt ': st) :-> (dt : st)
- case_ :: forall dt out inp. (InstrCaseC dt, RMap (CaseClauses dt)) => Rec (CaseClauseL inp out) (CaseClauses dt) -> (dt : inp) :-> out
- caseT :: forall dt out inp clauses. CaseTC dt out inp clauses => IsoRecTuple clauses -> (dt : inp) :-> out
- unsafeUnwrap_ :: forall dt name st. InstrUnwrapC dt name => Label name -> (dt : st) :-> (CtorOnlyField name dt ': st)
- type CaseTC dt out inp clauses = (InstrCaseC dt, RMap (CaseClauses dt), RecFromTuple clauses, clauses ~ Rec (CaseClauseL inp out) (CaseClauses dt))
- class CaseArrow name body clause | clause -> name, clause -> body where
- data CaseClauseL (inp :: [Type]) (out :: [Type]) (param :: CaseClauseParam) where
- CaseClauseL :: (AppendCtorField x inp :-> out) -> CaseClauseL inp out ('CaseClauseParam ctor x)
- type InstrConstructC dt = (GenericIsoValue dt, GInstrConstruct (GRep dt) ('[] :: [Type]))
- type ConstructorFieldTypes dt = GFieldTypes (GRep dt) ('[] :: [Type])
- data Rec (a :: u -> Type) (b :: [u]) where
- type (:!) (name :: Symbol) a = NamedF Identity a name
- type (:?) (name :: Symbol) a = NamedF Maybe a name
- getFieldOpen :: forall dt name res st. (InstrGetFieldC dt name, HasDupableGetters dt) => ('[GetFieldType dt name] :-> '[res, GetFieldType dt name]) -> ('[GetFieldType dt name] :-> '[res]) -> Label name -> (dt : st) :-> (res : (dt ': st))
- setFieldOpen :: forall dt name new st. InstrSetFieldC dt name => ('[new, GetFieldType dt name] :-> '[GetFieldType dt name]) -> Label name -> (new ': (dt ': st)) :-> (dt ': st)
Documentation
type HasField dt fname = (InstrGetFieldC dt fname, InstrSetFieldC dt fname) Source #
Allows field access and modification.
type HasFieldOfType dt fname fieldTy = (HasField dt fname, GetFieldType dt fname ~ fieldTy) Source #
Like HasField, but allows constrainting field type.
type family HasFieldsOfType (dt :: Type) (fs :: [NamedField]) :: Constraint where ... Source #
Shortcut for multiple HasFieldOfType constraints.
Equations
| HasFieldsOfType _ '[] = () | |
| HasFieldsOfType dt ((n := ty) ': fs) = (HasFieldOfType dt n ty, HasFieldsOfType dt fs) |
type (:=) n ty = 'NamedField n ty infixr 0 Source #
class HasDupableGetters a Source #
This marker typeclass is a requirement for the getField
(where it is imposed on the datatype), and it is supposed to be satisfied
in two cases:
- The entire datatype is
Dupable; - When the datatype has non-dupable fields, they are located so that
getFieldremains efficient.
The problem we are trying to solve here: without special care, getField
may become multiple times more costly, see instrGetField for the
explanation.
And this typeclass imposes an invariant: if we ever use getField on a
datatype, then we have to pay attention to the datatype's Michelson
representation and ensure getField remains optimal.
When you are developing a contract:
Lorentz.Layouts.NonDupable module contains utilities to help you
provide the necessary Michelson layout. In case you want to use your
custom layout but still allow getField for it, you can define an instance
for your type manually as an assurance that Michelson layout is optimal enough
to use getField on this type.
When you are developing a library:
Note that HasDupableGetters resolves to Dupable by default, and when
propagating this constraint you can switch to Dupable anytime but this
will also make your code unusable in the presence of Tickets and other
non-dupable types.
Instances
| Dupable a => HasDupableGetters (a :: Type) Source # | |
Defined in Lorentz.ADT | |
toField :: forall dt name st. InstrGetFieldC dt name => Label name -> (dt : st) :-> (GetFieldType dt name : st) Source #
Extract a field of a datatype replacing the value of this datatype with the extracted field.
For this and the following functions you have to specify field name
which is either record name or name attached with (:!) operator.
>>>:{(toField @TestProductWithNonDup #fieldTP -$ testProductWithNonDup) == testProduct :} True
toFieldNamed :: forall dt name st. InstrGetFieldC dt name => Label name -> (dt : st) :-> ((name :! GetFieldType dt name) : st) Source #
Like toField, but leaves field named.
getField :: forall dt name st. (InstrGetFieldC dt name, Dupable (GetFieldType dt name), HasDupableGetters dt) => Label name -> (dt : st) :-> (GetFieldType dt name : (dt ': st)) Source #
Extract a field of a datatype, leaving the original datatype on stack.
>>>:{(getField @TestProduct #fieldB # L.swap # toField @TestProduct #fieldB # mul) -$ testProduct { fieldB = 3 } :} 9
getFieldNamed :: forall dt name st. (InstrGetFieldC dt name, Dupable (GetFieldType dt name), HasDupableGetters dt) => Label name -> (dt : st) :-> ((name :! GetFieldType dt name) : (dt ': st)) Source #
Like getField, but leaves field named.
setField :: forall dt name st. InstrSetFieldC dt name => Label name -> (GetFieldType dt name ': (dt ': st)) :-> (dt ': st) Source #
Set a field of a datatype.
>>>setField @TestProduct #fieldB -$ 23 ::: testProductTestProduct {fieldA = True, fieldB = 23, fieldC = ()}
modifyField :: forall dt name st. (InstrGetFieldC dt name, InstrSetFieldC dt name, Dupable (GetFieldType dt name), HasDupableGetters dt) => Label name -> (forall st0. (GetFieldType dt name ': st0) :-> (GetFieldType dt name ': st0)) -> (dt : st) :-> (dt : st) Source #
Apply given modifier to a datatype field.
>>>modifyField @TestProduct #fieldB (dup # mul) -$ testProduct { fieldB = 8 }TestProduct {fieldA = True, fieldB = 64, fieldC = ()}
construct :: forall dt st. (InstrConstructC dt, RMap (ConstructorFieldTypes dt)) => Rec (FieldConstructor st) (ConstructorFieldTypes dt) -> st :-> (dt : st) Source #
Make up a datatype. You provide a pack of individual fields constructors.
Each element of the accepted record should be an instruction wrapped with
fieldCtor function. This instruction will have access to the stack at
the moment of calling construct.
Instructions have to output fields of the built datatype, one per instruction;
instructions order is expected to correspond to the order of fields in the
datatype.
>>>:{let ctor = (fieldCtor (push True)) :& (fieldCtor (push (42 :: Integer))) :& (fieldCtor (push ())) :& RNil :}
>>>construct @TestProduct ctor -$ ZSNilTestProduct {fieldA = True, fieldB = 42, fieldC = ()}
constructT :: forall dt fctors st. (InstrConstructC dt, RMap (ConstructorFieldTypes dt), fctors ~ Rec (FieldConstructor st) (ConstructorFieldTypes dt), RecFromTuple fctors) => IsoRecTuple fctors -> st :-> (dt : st) Source #
Version of construct which accepts tuple of field constructors.
>>>let ctor = (fieldCtor (push True), fieldCtor (push @Integer 42), fieldCtor (push ()))>>>constructT @TestProduct ctor -$ ZSNilTestProduct {fieldA = True, fieldB = 42, fieldC = ()}
constructStack :: forall dt fields st. (InstrConstructC dt, fields ~ ConstructorFieldTypes dt, (ToTs fields ++ ToTs st) ~ ToTs (fields ++ st)) => (fields ++ st) :-> (dt : st) Source #
Construct an object from fields on the stack.
>>>constructStack @TestProduct -$ True ::: 42 ::: ()TestProduct {fieldA = True, fieldB = 42, fieldC = ()}
deconstruct :: forall dt fields st. (InstrDeconstructC dt (ToTs st), fields ~ GFieldTypes (GRep dt) '[], (ToTs fields ++ ToTs st) ~ ToTs (fields ++ st)) => (dt : st) :-> (fields ++ st) Source #
Decompose a complex object into its fields
>>>deconstruct @TestProduct # constructStack @TestProduct -$ testProductTestProduct {fieldA = True, fieldB = 42, fieldC = ()}
Will show human-readable error on a missing Generic instance:
>>>data Foo = Foo () ()>>>deconstruct @Foo... ... GHC.Generics.Rep Foo ... is stuck. Likely ... Generic Foo ... instance is missing or out of scope. ...
>>>data Foo = Foo () () deriving (Generic, IsoValue)>>>pretty $ deconstruct @Foo[UNPAIR, DIP { }]
fieldCtor :: HasCallStack => (st :-> (f : st)) -> FieldConstructor st f Source #
Lift an instruction to field constructor.
wrap_ :: forall dt name st. InstrWrapC dt name => Label name -> AppendCtorField (GetCtorField dt name) st :-> (dt : st) Source #
Wrap entry in constructor. Useful for sum types.
>>>wrap_ @TestSum #cTestSumB -$ (False, ())TestSumB (False,())
wrapOne :: forall dt name st. InstrWrapOneC dt name => Label name -> (CtorOnlyField name dt ': st) :-> (dt : st) Source #
Wrap entry in single-field constructor. Useful for sum types.
>>>wrapOne @TestSum #cTestSumA -$ 42TestSumA 42
case_ :: forall dt out inp. (InstrCaseC dt, RMap (CaseClauses dt)) => Rec (CaseClauseL inp out) (CaseClauses dt) -> (dt : inp) :-> out Source #
Pattern match on the given sum type.
You have to provide a Rec containing case branches.
To construct a case branch use /-> operator.
>>>:{let caseTestSum = case_ @TestSum $ (#cTestSumA /-> nop) :& (#cTestSumB /-> L.drop # push 23) :& RNil :}
>>>caseTestSum -$ TestSumA 4242>>>caseTestSum -$ TestSumB (False, ())23
caseT :: forall dt out inp clauses. CaseTC dt out inp clauses => IsoRecTuple clauses -> (dt : inp) :-> out Source #
Like case_, accepts a tuple of clauses, which may be more convenient.
If user is experiencing problems with wierd errors about tuples while using this function, he should take look at Morley.Util.TypeTuple.Instances and ensure that his tuple isn't bigger than generated instances, if so, he should probably extend number of generated instances.
>>>:{let caseTTestSum = caseT @TestSum $ ( #cTestSumA /-> nop , #cTestSumB /-> L.drop # push 23 ) :}
>>>caseTTestSum -$ TestSumA 4242>>>caseTTestSum -$ TestSumB (False, ())23
unsafeUnwrap_ :: forall dt name st. InstrUnwrapC dt name => Label name -> (dt : st) :-> (CtorOnlyField name dt ': st) Source #
Unwrap a constructor with the given name. Useful for sum types.
>>>unsafeUnwrap_ @TestSum #cTestSumA -$? TestSumA 42Right 42>>>pretty $ unsafeUnwrap_ @TestSum #cTestSumA -$? TestSumB (False, ())<Left: Reached FAILWITH instruction with '"BadCtor"' at line 1 char 1.>
type CaseTC dt out inp clauses = (InstrCaseC dt, RMap (CaseClauses dt), RecFromTuple clauses, clauses ~ Rec (CaseClauseL inp out) (CaseClauses dt)) Source #
class CaseArrow name body clause | clause -> name, clause -> body where Source #
Provides "case" arrow which works on different wrappers for clauses.
Methods
(/->) :: Label name -> body -> clause infixr 0 Source #
Lift an instruction to case clause.
You should write out constructor name corresponding to the clause explicitly. Prefix constructor name with "c" letter, otherwise your label will not be recognized by Haskell parser. Passing constructor name can be circumvented but doing so is not recomended as mentioning contructor name improves readability and allows avoiding some mistakes.
Instances
| (name ~ AppendSymbol "c" ctor, body ~ (AppendCtorField x inp :-> out)) => CaseArrow name body (CaseClauseL inp out ('CaseClauseParam ctor x)) Source # | |
Defined in Lorentz.ADT Methods (/->) :: Label name -> body -> CaseClauseL inp out ('CaseClauseParam ctor x) Source # | |
data CaseClauseL (inp :: [Type]) (out :: [Type]) (param :: CaseClauseParam) where Source #
Lorentz analogy of CaseClause, it works on plain Type types.
Constructors
| CaseClauseL :: (AppendCtorField x inp :-> out) -> CaseClauseL inp out ('CaseClauseParam ctor x) |
Instances
| (name ~ AppendSymbol "c" ctor, body ~ (AppendCtorField x inp :-> out)) => CaseArrow name body (CaseClauseL inp out ('CaseClauseParam ctor x)) Source # | |
Defined in Lorentz.ADT Methods (/->) :: Label name -> body -> CaseClauseL inp out ('CaseClauseParam ctor x) Source # | |
type InstrConstructC dt = (GenericIsoValue dt, GInstrConstruct (GRep dt) ('[] :: [Type])) #
type ConstructorFieldTypes dt = GFieldTypes (GRep dt) ('[] :: [Type]) #
Useful re-exports
data Rec (a :: u -> Type) (b :: [u]) where #
A record is parameterized by a universe u, an interpretation f and a
list of rows rs. The labels or indices of the record are given by
inhabitants of the kind u; the type of values at any label r :: u is
given by its interpretation f r :: *.
Constructors
| RNil :: forall {u} (a :: u -> Type). Rec a ('[] :: [u]) | |
| (:&) :: forall {u} (a :: u -> Type) (r :: u) (rs :: [u]). !(a r) -> !(Rec a rs) -> Rec a (r ': rs) infixr 7 |
Instances
| RecSubset (Rec :: (k -> Type) -> [k] -> Type) ('[] :: [k]) (ss :: [k]) ('[] :: [Nat]) | |
Defined in Data.Vinyl.Lens Associated Types type RecSubsetFCtx Rec f # Methods rsubsetC :: forall g (f :: k0 -> Type). (Functor g, RecSubsetFCtx Rec f) => (Rec f '[] -> g (Rec f '[])) -> Rec f ss -> g (Rec f ss) # rcastC :: forall (f :: k0 -> Type). RecSubsetFCtx Rec f => Rec f ss -> Rec f '[] # rreplaceC :: forall (f :: k0 -> Type). RecSubsetFCtx Rec f => Rec f '[] -> Rec f ss -> Rec f ss # | |
| (RElem r ss i, RSubset rs ss is) => RecSubset (Rec :: (k -> Type) -> [k] -> Type) (r ': rs :: [k]) (ss :: [k]) (i ': is) | |
Defined in Data.Vinyl.Lens Associated Types type RecSubsetFCtx Rec f # Methods rsubsetC :: forall g (f :: k0 -> Type). (Functor g, RecSubsetFCtx Rec f) => (Rec f (r ': rs) -> g (Rec f (r ': rs))) -> Rec f ss -> g (Rec f ss) # rcastC :: forall (f :: k0 -> Type). RecSubsetFCtx Rec f => Rec f ss -> Rec f (r ': rs) # rreplaceC :: forall (f :: k0 -> Type). RecSubsetFCtx Rec f => Rec f (r ': rs) -> Rec f ss -> Rec f ss # | |
| RecElem (Rec :: (a -> Type) -> [a] -> Type) (r :: a) (r' :: a) (r ': rs :: [a]) (r' ': rs :: [a]) 'Z | |
Defined in Data.Vinyl.Lens Associated Types type RecElemFCtx Rec f # | |
| (RIndex r (s ': rs) ~ 'S i, RecElem (Rec :: (a -> Type) -> [a] -> Type) r r' rs rs' i) => RecElem (Rec :: (a -> Type) -> [a] -> Type) (r :: a) (r' :: a) (s ': rs :: [a]) (s ': rs' :: [a]) ('S i) | |
Defined in Data.Vinyl.Lens Associated Types type RecElemFCtx Rec f # | |
| TestCoercion f => TestCoercion (Rec f :: [u] -> Type) | |
Defined in Data.Vinyl.Core | |
| TestEquality f => TestEquality (Rec f :: [u] -> Type) | |
Defined in Data.Vinyl.Core | |
| (Storable (f r), Storable (Rec f rs)) => Storable (Rec f (r ': rs)) | |
Defined in Data.Vinyl.Core Methods sizeOf :: Rec f (r ': rs) -> Int # alignment :: Rec f (r ': rs) -> Int # peekElemOff :: Ptr (Rec f (r ': rs)) -> Int -> IO (Rec f (r ': rs)) # pokeElemOff :: Ptr (Rec f (r ': rs)) -> Int -> Rec f (r ': rs) -> IO () # peekByteOff :: Ptr b -> Int -> IO (Rec f (r ': rs)) # pokeByteOff :: Ptr b -> Int -> Rec f (r ': rs) -> IO () # | |
| Storable (Rec f ('[] :: [u])) | |
Defined in Data.Vinyl.Core | |
| (Monoid (f r), Monoid (Rec f rs)) => Monoid (Rec f (r ': rs)) | |
| Monoid (Rec f ('[] :: [u])) | |
| (Semigroup (f r), Semigroup (Rec f rs)) => Semigroup (Rec f (r ': rs)) | |
| Semigroup (Rec f ('[] :: [u])) | |
| Generic (Rec f rs) => Generic (Rec f (r ': rs)) | |
| Generic (Rec f ('[] :: [u])) | |
| (RMap rs, ReifyConstraint Show f rs, RecordToList rs) => Show (Rec f rs) | Records may be shown insofar as their points may be shown.
|
| ReifyConstraint NFData f xs => NFData (Rec f xs) | |
Defined in Data.Vinyl.Core | |
| (Eq (f r), Eq (Rec f rs)) => Eq (Rec f (r ': rs)) | |
| Eq (Rec f ('[] :: [u])) | |
| (Ord (f r), Ord (Rec f rs)) => Ord (Rec f (r ': rs)) | |
Defined in Data.Vinyl.Core Methods compare :: Rec f (r ': rs) -> Rec f (r ': rs) -> Ordering # (<) :: Rec f (r ': rs) -> Rec f (r ': rs) -> Bool # (<=) :: Rec f (r ': rs) -> Rec f (r ': rs) -> Bool # (>) :: Rec f (r ': rs) -> Rec f (r ': rs) -> Bool # (>=) :: Rec f (r ': rs) -> Rec f (r ': rs) -> Bool # max :: Rec f (r ': rs) -> Rec f (r ': rs) -> Rec f (r ': rs) # min :: Rec f (r ': rs) -> Rec f (r ': rs) -> Rec f (r ': rs) # | |
| Ord (Rec f ('[] :: [u])) | |
| type RecSubsetFCtx (Rec :: (k -> Type) -> [k] -> Type) (f :: k -> Type) | |
Defined in Data.Vinyl.Lens | |
| type RecSubsetFCtx (Rec :: (k -> Type) -> [k] -> Type) (f :: k -> Type) | |
Defined in Data.Vinyl.Lens | |
| type RecElemFCtx (Rec :: (a -> Type) -> [a] -> Type) (f :: a -> Type) | |
Defined in Data.Vinyl.Lens | |
| type RecElemFCtx (Rec :: (a -> Type) -> [a] -> Type) (f :: a -> Type) | |
Defined in Data.Vinyl.Lens | |
| type Rep (Rec f (r ': rs)) | |
Defined in Data.Vinyl.Core type Rep (Rec f (r ': rs)) = C1 ('MetaCons ":&" ('InfixI 'RightAssociative 7) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (f r)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rep (Rec f rs))) | |
| type Rep (Rec f ('[] :: [u])) | |
Defined in Data.Vinyl.Core | |
| type IsoRecTuple (Rec f '[a]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[a]) = f a | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14, f x15, f x16, f x17, f x18, f x19, f x20, f x21, f x22, f x23, f x24, f x25) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14, f x15, f x16, f x17, f x18, f x19, f x20, f x21, f x22, f x23, f x24) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14, f x15, f x16, f x17, f x18, f x19, f x20, f x21, f x22, f x23) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14, f x15, f x16, f x17, f x18, f x19, f x20, f x21, f x22) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14, f x15, f x16, f x17, f x18, f x19, f x20, f x21) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14, f x15, f x16, f x17, f x18, f x19, f x20) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14, f x15, f x16, f x17, f x18, f x19) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14, f x15, f x16, f x17, f x18) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14, f x15, f x16, f x17) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14, f x15, f x16) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14, f x15) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13, f x14) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12, f x13) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11, f x12) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10, f x11) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9, f x10) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8, x9]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8, f x9) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7, x8]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7, f x8) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6, x7]) = (f x1, f x2, f x3, f x4, f x5, f x6, f x7) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5, x6]) = (f x1, f x2, f x3, f x4, f x5, f x6) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4, x5]) = (f x1, f x2, f x3, f x4, f x5) | |
| type IsoRecTuple (Rec f '[x1, x2, x3, x4]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3, x4]) = (f x1, f x2, f x3, f x4) | |
| type IsoRecTuple (Rec f '[x1, x2, x3]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2, x3]) = (f x1, f x2, f x3) | |
| type IsoRecTuple (Rec f '[x1, x2]) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f '[x1, x2]) = (f x1, f x2) | |
| type IsoRecTuple (Rec f ('[] :: [u])) | |
Defined in Morley.Util.TypeTuple.Instances type IsoRecTuple (Rec f ('[] :: [u])) = () | |
type (:!) (name :: Symbol) a = NamedF Identity a name #
Infix notation for the type of a named parameter.
type (:?) (name :: Symbol) a = NamedF Maybe a name #
Infix notation for the type of an optional named parameter.
Advanced methods
getFieldOpen :: forall dt name res st. (InstrGetFieldC dt name, HasDupableGetters dt) => ('[GetFieldType dt name] :-> '[res, GetFieldType dt name]) -> ('[GetFieldType dt name] :-> '[res]) -> Label name -> (dt : st) :-> (res : (dt ': st)) Source #
"Open" version of getField, an advanced method suitable for chaining
getters.
It accepts two continuations accepting the extracted field, one that
leaves the field on stack (and does a duplication of res inside)
and another one that consumes the field. Normally these are just getField
and toField for some nested field.
Unlike the straightforward chaining of getField/toField methods,
getFieldOpen does not require the immediate field to be dupable; rather,
in the best case only res has to be dupable.
setFieldOpen :: forall dt name new st. InstrSetFieldC dt name => ('[new, GetFieldType dt name] :-> '[GetFieldType dt name]) -> Label name -> (new ': (dt ': st)) :-> (dt ': st) Source #
"Open" version of setField, an advanced method suitable for chaining
setters.
It accepts a continuation accepting the field extracted for the update and
the new value that is being set. Normally this continuation is just setField
for some nested field.
Definitions used in examples
>>>import Data.Vinyl (Rec(..))>>>import Fmt (pretty)>>>import Lorentz.Base ((#))>>>import Lorentz.Instr as L>>>import Lorentz.Zip (ZippedStackRepr(..), ZSNil(..))>>>import Lorentz.Run.Simple ((-$), (-$?))>>>import Morley.Michelson.Runtime.Dummy (dummySelf)>>>import Morley.Michelson.Typed (IsoValue(..))>>>import Morley.Michelson.Typed.Haskell.Value (Ticket(..))>>>import Morley.Tezos.Address (Constrained(..))>>>:{data TestProduct = TestProduct { fieldA :: Bool , fieldB :: Integer , fieldC :: () } deriving stock (Generic, Eq, Show) deriving anyclass (IsoValue) -- data TestProductWithNonDup = TestProductWithNonDup { fieldTP :: TestProduct , fieldD :: Ticket () -- non-dupable value } deriving stock (Generic, Eq, Show) deriving anyclass (IsoValue) -- data TestSum = TestSumA Integer | TestSumB (Bool, ()) deriving stock (Generic, Eq, Show) deriving anyclass (IsoValue) :}
>>>let testTicket = Ticket (Constrained dummySelf) () 10>>>let testProduct = TestProduct True 42 ()>>>let testProductWithNonDup = TestProductWithNonDup testProduct testTicket