Safe Haskell | None |
---|---|
Language | Haskell2010 |
Backend statements for variable manipulation: assignment, replacement, update.
Synopsis
- assignVar :: KnownValue x => Var x -> Expr x -> IndigoState inp (x & inp)
- setVar :: forall a inp. KnownValue a => RefId -> Var a -> Expr a -> IndigoState inp inp
- setField :: forall dt fname ftype inp. (IsObject dt, IsObject ftype, HasField dt fname ftype) => RefId -> Var dt -> Label fname -> Expr ftype -> IndigoState inp inp
- updateVar :: forall x y inp. (IsObject x, KnownValue y) => RefId -> ([y, x] :-> '[x]) -> Var x -> Expr y -> IndigoState inp inp
Documentation
assignVar :: KnownValue x => Var x -> Expr x -> IndigoState inp (x & inp) Source #
Assign the given variable to the value resulting from the given expression.
setVar :: forall a inp. KnownValue a => RefId -> Var a -> Expr a -> IndigoState inp inp Source #
Set the variable to a new value.
If a variable is a cell on the stack,
we just compile passed expression and replace variable cell on stack.
If a variable is decomposed, we decompose passed expression
and call setVar
recursively from its fields.
Pay attention that this function takes a next RefId but it doesn't return RefId because all allocated variables will be destroyed during execution of the function, so allocated ones won't affect next allocated ones.
setField :: forall dt fname ftype inp. (IsObject dt, IsObject ftype, HasField dt fname ftype) => RefId -> Var dt -> Label fname -> Expr ftype -> IndigoState inp inp Source #
Set the field (direct or indirect) of a complex object.
updateVar :: forall x y inp. (IsObject x, KnownValue y) => RefId -> ([y, x] :-> '[x]) -> Var x -> Expr y -> IndigoState inp inp Source #
Call binary operator with constant argument to update a variable in-place.