indigo-0.6.0: Convenient imperative eDSL over Lorentz.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Indigo.Backend.Var

Description

Backend statements for variable manipulation: assignment, replacement, update.

Synopsis

Documentation

assignVar :: forall x inp. 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.