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

Indigo.Backend.Conditional

Description

Backend conditional statements of Indigo

Synopsis

Documentation

if_ Source #

Arguments

:: forall inp a b. IfConstraint a b 
=> Expr Bool

Expression for the control flow

-> SomeIndigoState inp

Code block for the positive branch

-> a

Return value(s) of the positive branch

-> SomeIndigoState inp

Code block for the negative branch

-> b

Return value(s) of the negative branch

-> RetVars a

Variable(s) that will be assigned to the resulting value(s)

-> IndigoState inp (RetOutStack a ++ inp) 

If statement. All variables created inside its branches will be released after the execution leaves the scope in which they were created.

ifSome Source #

Arguments

:: forall inp x a b. (IfConstraint a b, KnownValue x) 
=> Expr (Maybe x)

Expression for the control flow

-> Var x

Variable for the Just value (available to the next code block)

-> SomeIndigoState (x ': inp)

Code block for the Just branch

-> a

Return value(s) of the Just branch

-> SomeIndigoState inp

Code block for the Nothing branch

-> b

Return value(s) of the Nothing branch

-> RetVars a

Variable(s) that will be assigned to the resulting value(s)

-> IndigoState inp (RetOutStack a ++ inp) 

If-statement that works like case for Maybe.

ifRight Source #

Arguments

:: forall inp r l a b. (IfConstraint a b, KnownValue r, KnownValue l) 
=> Expr (Either l r)

Expression for the control flow

-> Var r

Variable for the Right value (available to the next code block)

-> SomeIndigoState (r ': inp)

Code block for the Right branch

-> a

Return value(s) of the Right branch

-> Var l

Variable for the Left value (available to the next code block)

-> SomeIndigoState (l ': inp)

Code block for the Left branch

-> b

Return value(s) of the Left branch

-> RetVars a

Variable(s) that will be assigned to the resulting value(s)

-> IndigoState inp (RetOutStack a ++ inp) 

If which works like case for Either.

ifCons Source #

Arguments

:: forall inp x a b. (IfConstraint a b, KnownValue x) 
=> Expr (List x)

Expression for the control flow

-> Var x

Variable for the "head" value (available to the next code block)

-> Var (List x)

Variable for the "tail" value (available to the next code block)

-> SomeIndigoState (x ': (List x ': inp))

Code block for the non-empty list branch

-> a

Return value(s) of the non-empty list branch

-> SomeIndigoState inp

Code block for the empty list branch

-> b

Return value(s) of the empty list branch

-> RetVars a

Variable(s) that will be assigned to the resulting value(s)

-> IndigoState inp (RetOutStack a ++ inp) 

If which works like uncons for lists.

type IfConstraint a b = (ScopeCodeGen a, ScopeCodeGen b, CompareBranchesResults (RetExprs a) (RetExprs b), RetVars a ~ RetVars b, RetOutStack a ~ RetOutStack b) Source #