module Indigo.Frontend.Language
(
new
, setVar
, setField
, (+=)
, (-=)
, (*=)
, (<<<=)
, (>>>=)
, (&&=)
, (||=)
, (^=)
, (=:)
, getStorageField
, setStorageField
, updateStorageField
, if_
, when
, unless
, ifSome
, ifNone
, whenSome
, whenNone
, ifRight
, ifLeft
, whenRight
, whenLeft
, ifCons
, case_
, caseRec
, entryCase
, entryCaseRec
, entryCaseSimple
, (//->)
, (#=)
, scope
, defFunction
, defContract
, defNamedPureLambda1
, defNamedLambda1
, defNamedLambda0
, defNamedEffLambda1
, while
, whileLeft
, forEach
, selfCalling
, contractCalling
, doc
, docGroup
, docStorage
, contractName
, contractGeneral
, contractGeneralDefault
, finalizeParamCallingDoc
, anchor
, description
, example
, transferTokens
, setDelegate
, createContract
, createLorentzContract
, emit
, failWith
, assert
, failCustom
, failCustom_
, failCustomNoArg
, failUnexpected_
, assertCustom
, assertCustom_
, assertCustomNoArg
, assertSome
, assertNone
, assertRight
, assertLeft
, ReturnableValue
, RetVars
, FieldAnn
, annQ
, comment
, justComment
, commentAroundFun
, commentAroundStmt
, IndigoFunction
, IndigoProcedure
, IndigoEntrypoint
, liftIndigoState
) where
import Fmt (Buildable)
import GHC.Stack (popCallStack)
import GHC.Stack.Types (SrcLoc(..))
import Indigo.Backend qualified as B
import Indigo.Backend.Case hiding (caseRec, entryCaseRec)
import Indigo.Backend.Lambda
import Indigo.Backend.Scope
import Indigo.Common.Expr (Expr(C), ExprType, IsExpr, ToExpr, toExpr, type (:~>))
import Indigo.Common.Field (HasField)
import Indigo.Common.Object (IsObject)
import Indigo.Common.SIS (SomeIndigoState, toSIS)
import Indigo.Common.Var (HasSideEffects, HasStorage, Var, storageVar)
import Indigo.Compilation (compileIndigoContract)
import Indigo.Frontend.Expr ((#!))
import Indigo.Frontend.Internal.Statement
import Indigo.Frontend.Program
import Indigo.Lorentz hiding (comment, commentAroundFun, commentAroundStmt, justComment)
import Indigo.Prelude
import Lorentz.Entrypoints.Helpers (RequireSumType)
import Lorentz.Instr qualified as L
import Lorentz.Run qualified as L
import Morley.Michelson.Typed qualified as MT
import Morley.Michelson.Typed.Arith qualified as M
import Morley.Michelson.Typed.Haskell.Instr.Sum (CaseClauseParam(..), CtorField(..))
import Morley.Michelson.Untyped.Annotation (FieldAnn, annQ)
import Morley.Util.Markdown (toAnchor)
import Morley.Util.TypeLits (AppendSymbol)
import Morley.Util.TypeTuple.Class
import Prelude ((==))
oneIndigoM :: StatementF IndigoM a -> IndigoM a
oneIndigoM :: forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM StatementF IndigoM a
st = Program (StatementF IndigoM) a -> IndigoM a
forall a. Program (StatementF IndigoM) a -> IndigoM a
IndigoM (StatementF IndigoM a -> Program (StatementF IndigoM) a
forall (instr :: * -> *) a. instr a -> Program instr a
Instr StatementF IndigoM a
st)
calledFrom :: HasCallStack => IndigoM a -> IndigoM a
calledFrom :: forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom IndigoM a
iM = case CallStack -> [([Char], SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack of
[] -> Text -> IndigoM a
forall a. HasCallStack => Text -> a
error Text
"impossible: calledFrom has HasCallStack constraint, so at least one element has to be at the callStack"
(([Char]
_, SrcLoc
loc):[([Char], SrcLoc)]
_)
| SrcLoc -> [Char]
srcLocModule SrcLoc
loc [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
"Indigo.Frontend.Language" ->
Program (StatementF IndigoM) a -> IndigoM a
forall a. Program (StatementF IndigoM) a -> IndigoM a
IndigoM (Program (StatementF IndigoM) a -> IndigoM a)
-> (IndigoM a -> Program (StatementF IndigoM) a)
-> IndigoM a
-> IndigoM a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM a -> Program (StatementF IndigoM) a
forall (instr :: * -> *) a. instr a -> Program instr a
Instr (StatementF IndigoM a -> Program (StatementF IndigoM) a)
-> (IndigoM a -> StatementF IndigoM a)
-> IndigoM a
-> Program (StatementF IndigoM) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CallStack -> IndigoM a -> StatementF IndigoM a
forall (freer :: * -> *) a.
CallStack -> freer a -> StatementF freer a
CalledFrom (CallStack -> CallStack
popCallStack CallStack
HasCallStack => CallStack
callStack) (IndigoM a -> IndigoM a) -> IndigoM a -> IndigoM a
forall a b. (a -> b) -> a -> b
$ IndigoM a
iM
| Bool
otherwise -> Text -> IndigoM a
forall a. HasCallStack => Text -> a
error (Text -> IndigoM a) -> Text -> IndigoM a
forall a b. (a -> b) -> a -> b
$ [Char] -> Text
forall a. IsString a => [Char] -> a
fromString ([Char] -> Text) -> [Char] -> Text
forall a b. (a -> b) -> a -> b
$
[Char]
"Misuse of calledFrom: the call made from " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ SrcLoc -> [Char]
srcLocModule SrcLoc
loc [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
". " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
[Char]
"You've either forgotten to specify HasCallStack constraint for exported Indigo frontend function or " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
[Char]
"exported calledFrom and called outside of Indigo.Frontend.Language module. " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
[Char]
"Please, report this issue to Indigo developers."
liftIndigoState :: (forall inp. SomeIndigoState inp) -> IndigoM ()
liftIndigoState :: (forall (inp :: [*]). SomeIndigoState inp) -> IndigoM ()
liftIndigoState forall (inp :: [*]). SomeIndigoState inp
code = Program (StatementF IndigoM) () -> IndigoM ()
forall a. Program (StatementF IndigoM) a -> IndigoM a
IndigoM (StatementF IndigoM () -> Program (StatementF IndigoM) ()
forall (instr :: * -> *) a. instr a -> Program instr a
Instr (StatementF IndigoM () -> Program (StatementF IndigoM) ())
-> StatementF IndigoM () -> Program (StatementF IndigoM) ()
forall a b. (a -> b) -> a -> b
$ (forall (inp :: [*]). SomeIndigoState inp) -> StatementF IndigoM ()
forall (freer :: * -> *).
(forall (inp :: [*]). SomeIndigoState inp) -> StatementF freer ()
LiftIndigoState forall (inp :: [*]). SomeIndigoState inp
code)
varModification
:: (IsExpr ey y, IsObject x)
=> ([y, x] :-> '[x]) -> Var x -> ey -> IndigoM ()
varModification :: forall ey y x.
(IsExpr ey y, IsObject x) =>
('[y, x] :-> '[x]) -> Var x -> ey -> IndigoM ()
varModification '[y, x] :-> '[x]
act Var x
v = StatementF IndigoM () -> IndigoM ()
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM () -> IndigoM ())
-> (ey -> StatementF IndigoM ()) -> ey -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ('[y, x] :-> '[x]) -> Var x -> Expr y -> StatementF IndigoM ()
forall x y (freer :: * -> *).
(IsObject x, KnownValue y) =>
('[y, x] :-> '[x]) -> Var x -> Expr y -> StatementF freer ()
VarModification '[y, x] :-> '[x]
act Var x
v (Expr y -> StatementF IndigoM ())
-> (ey -> Expr y) -> ey -> StatementF IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ey -> Expr y
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr
new :: (IsExpr ex x, HasCallStack) => ex -> IndigoM (Var x)
new :: forall ex x. (IsExpr ex x, HasCallStack) => ex -> IndigoM (Var x)
new = IndigoM (Var x) -> IndigoM (Var x)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (Var x) -> IndigoM (Var x))
-> (ex -> IndigoM (Var x)) -> ex -> IndigoM (Var x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM (Var x) -> IndigoM (Var x)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (Var x) -> IndigoM (Var x))
-> (ex -> StatementF IndigoM (Var x)) -> ex -> IndigoM (Var x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr x -> StatementF IndigoM (Var x)
forall x (freer :: * -> *).
KnownValue x =>
Expr x -> StatementF freer (Var x)
NewVar (Expr x -> StatementF IndigoM (Var x))
-> (ex -> Expr x) -> ex -> StatementF IndigoM (Var x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr x
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr
setVar :: (IsExpr ex x, HasCallStack) => Var x -> ex -> IndigoM ()
setVar :: forall ex x.
(IsExpr ex x, HasCallStack) =>
Var x -> ex -> IndigoM ()
setVar Var x
v = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (ex -> IndigoM ()) -> ex -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM () -> IndigoM ()
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM () -> IndigoM ())
-> (ex -> StatementF IndigoM ()) -> ex -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Var x -> Expr x -> StatementF IndigoM ()
forall x (freer :: * -> *).
KnownValue x =>
Var x -> Expr x -> StatementF freer ()
SetVar Var x
v (Expr x -> StatementF IndigoM ())
-> (ex -> Expr x) -> ex -> StatementF IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr x
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr
infixr 0 =:
(=:) :: (IsExpr ex x, HasCallStack) => Var x -> ex -> IndigoM ()
Var x
v =: :: forall ex x.
(IsExpr ex x, HasCallStack) =>
Var x -> ex -> IndigoM ()
=: ex
e = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ Var x -> ex -> IndigoM ()
forall ex x.
(IsExpr ex x, HasCallStack) =>
Var x -> ex -> IndigoM ()
setVar Var x
v ex
e
setField
:: ( ex :~> ftype
, IsObject dt
, IsObject ftype
, HasField dt fname ftype
, HasCallStack
)
=> Var dt -> Label fname -> ex -> IndigoM ()
setField :: forall ex ftype dt (fname :: Symbol).
(ex :~> ftype, IsObject dt, IsObject ftype,
HasField dt fname ftype, HasCallStack) =>
Var dt -> Label fname -> ex -> IndigoM ()
setField Var dt
v Label fname
fName = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (ex -> IndigoM ()) -> ex -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM () -> IndigoM ()
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM () -> IndigoM ())
-> (ex -> StatementF IndigoM ()) -> ex -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Var dt -> Label fname -> Expr ftype -> StatementF IndigoM ()
forall dt ftype (fname :: Symbol) (freer :: * -> *).
(IsObject dt, IsObject ftype, HasField dt fname ftype) =>
Var dt -> Label fname -> Expr ftype -> StatementF freer ()
SetField Var dt
v Label fname
fName (Expr ftype -> StatementF IndigoM ())
-> (ex -> Expr ftype) -> ex -> StatementF IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr ftype
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr
(+=)
:: ( IsExpr ex1 n, IsObject m
, ArithOpHs M.Add n m m
, HasCallStack
) => Var m -> ex1 -> IndigoM ()
+= :: forall ex1 n m.
(IsExpr ex1 n, IsObject m, ArithOpHs Add n m m, HasCallStack) =>
Var m -> ex1 -> IndigoM ()
(+=) = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (Var m -> ex1 -> IndigoM ()) -> Var m -> ex1 -> IndigoM ()
forall a b c. SuperComposition a b c => a -> b -> c
... ('[n, m] :-> '[m]) -> Var m -> ex1 -> IndigoM ()
forall ey y x.
(IsExpr ey y, IsObject x) =>
('[y, x] :-> '[x]) -> Var x -> ey -> IndigoM ()
varModification '[n, m] :-> '[m]
forall n m r (s :: [*]).
ArithOpHs Add n m r =>
(n : m : s) :-> (r : s)
L.add
(-=)
:: ( IsExpr ex1 n, IsObject m
, ArithOpHs M.Sub n m m
, HasCallStack
) => Var m -> ex1 -> IndigoM ()
-= :: forall ex1 n m.
(IsExpr ex1 n, IsObject m, ArithOpHs Sub n m m, HasCallStack) =>
Var m -> ex1 -> IndigoM ()
(-=) = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (Var m -> ex1 -> IndigoM ()) -> Var m -> ex1 -> IndigoM ()
forall a b c. SuperComposition a b c => a -> b -> c
... ('[n, m] :-> '[m]) -> Var m -> ex1 -> IndigoM ()
forall ey y x.
(IsExpr ey y, IsObject x) =>
('[y, x] :-> '[x]) -> Var x -> ey -> IndigoM ()
varModification '[n, m] :-> '[m]
forall n m r (s :: [*]).
ArithOpHs Sub n m r =>
(n : m : s) :-> (r : s)
L.sub
(*=)
:: ( IsExpr ex1 n, IsObject m
, ArithOpHs M.Mul n m m
, HasCallStack
) => Var m -> ex1 -> IndigoM ()
*= :: forall ex1 n m.
(IsExpr ex1 n, IsObject m, ArithOpHs Mul n m m, HasCallStack) =>
Var m -> ex1 -> IndigoM ()
(*=) = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (Var m -> ex1 -> IndigoM ()) -> Var m -> ex1 -> IndigoM ()
forall a b c. SuperComposition a b c => a -> b -> c
... ('[n, m] :-> '[m]) -> Var m -> ex1 -> IndigoM ()
forall ey y x.
(IsExpr ey y, IsObject x) =>
('[y, x] :-> '[x]) -> Var x -> ey -> IndigoM ()
varModification '[n, m] :-> '[m]
forall n m r (s :: [*]).
ArithOpHs Mul n m r =>
(n : m : s) :-> (r : s)
L.mul
(||=)
:: ( IsExpr ex1 n, IsObject m
, ArithOpHs M.Or n m m
, HasCallStack
) => Var m -> ex1 -> IndigoM ()
||= :: forall ex1 n m.
(IsExpr ex1 n, IsObject m, ArithOpHs Or n m m, HasCallStack) =>
Var m -> ex1 -> IndigoM ()
(||=) = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (Var m -> ex1 -> IndigoM ()) -> Var m -> ex1 -> IndigoM ()
forall a b c. SuperComposition a b c => a -> b -> c
... ('[n, m] :-> '[m]) -> Var m -> ex1 -> IndigoM ()
forall ey y x.
(IsExpr ey y, IsObject x) =>
('[y, x] :-> '[x]) -> Var x -> ey -> IndigoM ()
varModification '[n, m] :-> '[m]
forall n m r (s :: [*]).
ArithOpHs Or n m r =>
(n : m : s) :-> (r : s)
L.or
(&&=)
:: ( IsExpr ex1 n, IsObject m
, ArithOpHs M.And n m m
, HasCallStack
) => Var m -> ex1 -> IndigoM ()
&&= :: forall ex1 n m.
(IsExpr ex1 n, IsObject m, ArithOpHs And n m m, HasCallStack) =>
Var m -> ex1 -> IndigoM ()
(&&=) = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (Var m -> ex1 -> IndigoM ()) -> Var m -> ex1 -> IndigoM ()
forall a b c. SuperComposition a b c => a -> b -> c
... ('[n, m] :-> '[m]) -> Var m -> ex1 -> IndigoM ()
forall ey y x.
(IsExpr ey y, IsObject x) =>
('[y, x] :-> '[x]) -> Var x -> ey -> IndigoM ()
varModification '[n, m] :-> '[m]
forall n m r (s :: [*]).
ArithOpHs And n m r =>
(n : m : s) :-> (r : s)
L.and
(^=)
:: ( IsExpr ex1 n, IsObject m
, ArithOpHs M.Xor n m m
, HasCallStack
) => Var m -> ex1 -> IndigoM ()
^= :: forall ex1 n m.
(IsExpr ex1 n, IsObject m, ArithOpHs Xor n m m, HasCallStack) =>
Var m -> ex1 -> IndigoM ()
(^=) = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (Var m -> ex1 -> IndigoM ()) -> Var m -> ex1 -> IndigoM ()
forall a b c. SuperComposition a b c => a -> b -> c
... ('[n, m] :-> '[m]) -> Var m -> ex1 -> IndigoM ()
forall ey y x.
(IsExpr ey y, IsObject x) =>
('[y, x] :-> '[x]) -> Var x -> ey -> IndigoM ()
varModification '[n, m] :-> '[m]
forall n m r (s :: [*]).
ArithOpHs Xor n m r =>
(n : m : s) :-> (r : s)
L.xor
(<<<=)
:: ( IsExpr ex1 n, IsObject m
, ArithOpHs M.Lsl n m m
, HasCallStack
) => Var m -> ex1 -> IndigoM ()
<<<= :: forall ex1 n m.
(IsExpr ex1 n, IsObject m, ArithOpHs Lsl n m m, HasCallStack) =>
Var m -> ex1 -> IndigoM ()
(<<<=) = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (Var m -> ex1 -> IndigoM ()) -> Var m -> ex1 -> IndigoM ()
forall a b c. SuperComposition a b c => a -> b -> c
... ('[n, m] :-> '[m]) -> Var m -> ex1 -> IndigoM ()
forall ey y x.
(IsExpr ey y, IsObject x) =>
('[y, x] :-> '[x]) -> Var x -> ey -> IndigoM ()
varModification '[n, m] :-> '[m]
forall n m r (s :: [*]).
ArithOpHs Lsl n m r =>
(n : m : s) :-> (r : s)
L.lsl
(>>>=)
:: ( IsExpr ex1 n, IsObject m
, ArithOpHs M.Lsr n m m
, HasCallStack
) => Var m -> ex1 -> IndigoM ()
>>>= :: forall ex1 n m.
(IsExpr ex1 n, IsObject m, ArithOpHs Lsr n m m, HasCallStack) =>
Var m -> ex1 -> IndigoM ()
(>>>=) = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (Var m -> ex1 -> IndigoM ()) -> Var m -> ex1 -> IndigoM ()
forall a b c. SuperComposition a b c => a -> b -> c
... ('[n, m] :-> '[m]) -> Var m -> ex1 -> IndigoM ()
forall ey y x.
(IsExpr ey y, IsObject x) =>
('[y, x] :-> '[x]) -> Var x -> ey -> IndigoM ()
varModification '[n, m] :-> '[m]
forall n m r (s :: [*]).
ArithOpHs Lsr n m r =>
(n : m : s) :-> (r : s)
L.lsr
setStorageField
:: forall store name ftype ex.
( HasStorage store
, ex :~> ftype
, IsObject store
, IsObject ftype
, HasField store name ftype
, HasCallStack
)
=> Label name -> ex -> IndigoM ()
setStorageField :: forall store (name :: Symbol) ftype ex.
(HasStorage store, ex :~> ftype, IsObject store, IsObject ftype,
HasField store name ftype, HasCallStack) =>
Label name -> ex -> IndigoM ()
setStorageField Label name
field ex
expr = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ Var store -> Label name -> ex -> IndigoM ()
forall ex ftype dt (fname :: Symbol).
(ex :~> ftype, IsObject dt, IsObject ftype,
HasField dt fname ftype, HasCallStack) =>
Var dt -> Label fname -> ex -> IndigoM ()
setField (forall st. HasStorage st => Var st
storageVar @store) Label name
field ex
expr
updateStorageField
:: forall store ftype fname fex.
( HasStorage store
, fex :~> ftype
, HasField store fname ftype
, IsObject store
, IsObject ftype
, HasCallStack
)
=> Label fname
-> (Var ftype -> IndigoM fex)
-> IndigoM ()
updateStorageField :: forall store ftype (fname :: Symbol) fex.
(HasStorage store, fex :~> ftype, HasField store fname ftype,
IsObject store, IsObject ftype, HasCallStack) =>
Label fname -> (Var ftype -> IndigoM fex) -> IndigoM ()
updateStorageField Label fname
field Var ftype -> IndigoM fex
upd = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ IndigoM () -> IndigoFunction ()
forall a.
(ScopeCodeGen a, HasCallStack) =>
IndigoM a -> IndigoFunction a
scope (IndigoM () -> IndigoFunction ())
-> IndigoM () -> IndigoFunction ()
forall a b. (a -> b) -> a -> b
$ do
let storage :: Var store
storage = forall st. HasStorage st => Var st
storageVar @store
Var ftype
fieldVar <- Expr ftype -> IndigoM (Var ftype)
forall ex x. (IsExpr ex x, HasCallStack) => ex -> IndigoM (Var x)
new(Expr ftype -> IndigoM (Var ftype))
-> Expr ftype -> IndigoM (Var ftype)
forall a b. (a -> b) -> a -> b
$ Var store
storage Var store -> Label fname -> Expr ftype
forall dt (name :: Symbol) ftype exDt.
(HasField dt name ftype, exDt :~> dt) =>
exDt -> Label name -> Expr ftype
#! Label fname
field
fex
expr <- Var ftype -> IndigoM fex
upd Var ftype
fieldVar
Var store -> Label fname -> fex -> IndigoM ()
forall ex ftype dt (fname :: Symbol).
(ex :~> ftype, IsObject dt, IsObject ftype,
HasField dt fname ftype, HasCallStack) =>
Var dt -> Label fname -> ex -> IndigoM ()
setField Var store
storage Label fname
field fex
expr
getStorageField
:: forall store ftype fname .
( HasStorage store
, HasField store fname ftype
, HasCallStack
)
=> Label fname -> IndigoM (Var ftype)
getStorageField :: forall store ftype (fname :: Symbol).
(HasStorage store, HasField store fname ftype, HasCallStack) =>
Label fname -> IndigoM (Var ftype)
getStorageField Label fname
field = IndigoM (Var ftype) -> IndigoM (Var ftype)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (Var ftype) -> IndigoM (Var ftype))
-> IndigoM (Var ftype) -> IndigoM (Var ftype)
forall a b. (a -> b) -> a -> b
$ Expr ftype -> IndigoM (Var ftype)
forall ex x. (IsExpr ex x, HasCallStack) => ex -> IndigoM (Var x)
new(Expr ftype -> IndigoM (Var ftype))
-> Expr ftype -> IndigoM (Var ftype)
forall a b. (a -> b) -> a -> b
$ forall st. HasStorage st => Var st
storageVar @store Var store -> Label fname -> Expr ftype
forall dt (name :: Symbol) ftype exDt.
(HasField dt name ftype, exDt :~> dt) =>
exDt -> Label name -> Expr ftype
#! Label fname
field
if_
:: forall a b ex . (IfConstraint a b, ex :~> Bool, HasCallStack)
=> ex
-> IndigoM a
-> IndigoM b
-> IndigoM (RetVars a)
if_ :: forall a b ex.
(IfConstraint a b, ex :~> Bool, HasCallStack) =>
ex -> IndigoM a -> IndigoM b -> IndigoM (RetVars a)
if_ ex
ex IndigoM a
tb IndigoM b
fb = IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars b) -> IndigoM (RetVars b))
-> IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars b) -> IndigoM (RetVars b))
-> StatementF IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a b. (a -> b) -> a -> b
$ Expr Bool
-> IndigoM a -> IndigoM b -> StatementF IndigoM (RetVars a)
forall a1 b (freer :: * -> *).
IfConstraint a1 b =>
Expr Bool
-> freer a1
-> freer b
-> StatementF freer (RetVars' (ClassifyReturnValue a1) a1)
If (ex -> Expr (ExprType ex)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex
ex) IndigoM a
tb IndigoM b
fb
when :: (exc :~> Bool, HasCallStack) => exc -> IndigoM () -> IndigoM ()
when :: forall exc.
(exc :~> Bool, HasCallStack) =>
exc -> IndigoM () -> IndigoM ()
when exc
cond IndigoM ()
expr = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ exc -> IndigoM () -> IndigoM () -> IndigoFunction ()
forall a b ex.
(IfConstraint a b, ex :~> Bool, HasCallStack) =>
ex -> IndigoM a -> IndigoM b -> IndigoM (RetVars a)
if_ exc
cond IndigoM ()
expr (() -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
unless :: (exc :~> Bool, HasCallStack) => exc -> IndigoM () -> IndigoM ()
unless :: forall exc.
(exc :~> Bool, HasCallStack) =>
exc -> IndigoM () -> IndigoM ()
unless exc
cond IndigoM ()
expr = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ exc -> IndigoM () -> IndigoM () -> IndigoFunction ()
forall a b ex.
(IfConstraint a b, ex :~> Bool, HasCallStack) =>
ex -> IndigoM a -> IndigoM b -> IndigoM (RetVars a)
if_ exc
cond (() -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()) IndigoM ()
expr
ifSome
:: forall x a b ex . (KnownValue x, ex :~> Maybe x, IfConstraint a b, HasCallStack)
=> ex
-> (Var x -> IndigoM a)
-> IndigoM b
-> IndigoM (RetVars a)
ifSome :: forall x a b ex.
(KnownValue x, ex :~> Maybe x, IfConstraint a b, HasCallStack) =>
ex -> (Var x -> IndigoM a) -> IndigoM b -> IndigoM (RetVars a)
ifSome ex
ex Var x -> IndigoM a
tb IndigoM b
fb = IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars b) -> IndigoM (RetVars b))
-> IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars b) -> IndigoM (RetVars b))
-> StatementF IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a b. (a -> b) -> a -> b
$ Expr (Maybe x)
-> (Var x -> IndigoM a)
-> IndigoM b
-> StatementF IndigoM (RetVars a)
forall a1 b x (freer :: * -> *).
(IfConstraint a1 b, KnownValue x) =>
Expr (Maybe x)
-> (Var x -> freer a1)
-> freer b
-> StatementF freer (RetVars' (ClassifyReturnValue a1) a1)
IfSome (ex -> Expr (ExprType ex)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex
ex) Var x -> IndigoM a
tb IndigoM b
fb
ifNone
:: forall x a b ex . (KnownValue x, ex :~> Maybe x, IfConstraint a b, HasCallStack)
=> ex
-> IndigoM b
-> (Var x -> IndigoM a)
-> IndigoM (RetVars a)
ifNone :: forall x a b ex.
(KnownValue x, ex :~> Maybe x, IfConstraint a b, HasCallStack) =>
ex -> IndigoM b -> (Var x -> IndigoM a) -> IndigoM (RetVars a)
ifNone ex
ex IndigoM b
fb Var x -> IndigoM a
tb = IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars b) -> IndigoM (RetVars b))
-> IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a b. (a -> b) -> a -> b
$ Expr (Maybe x)
-> (Var x -> IndigoM a) -> IndigoM b -> IndigoM (RetVars a)
forall x a b ex.
(KnownValue x, ex :~> Maybe x, IfConstraint a b, HasCallStack) =>
ex -> (Var x -> IndigoM a) -> IndigoM b -> IndigoM (RetVars a)
ifSome (ex -> Expr (ExprType ex)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex
ex) Var x -> IndigoM a
tb IndigoM b
fb
whenSome
:: forall x exa .
( KnownValue x
, exa :~> Maybe x
, HasCallStack
)
=> exa
-> (Var x -> IndigoM ())
-> IndigoM ()
whenSome :: forall x exa.
(KnownValue x, exa :~> Maybe x, HasCallStack) =>
exa -> (Var x -> IndigoM ()) -> IndigoM ()
whenSome exa
c Var x -> IndigoM ()
f = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ exa -> (Var x -> IndigoM ()) -> IndigoM () -> IndigoFunction ()
forall x a b ex.
(KnownValue x, ex :~> Maybe x, IfConstraint a b, HasCallStack) =>
ex -> (Var x -> IndigoM a) -> IndigoM b -> IndigoM (RetVars a)
ifSome exa
c Var x -> IndigoM ()
f (() -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
whenNone
:: forall x exa .
( KnownValue x
, exa :~> Maybe x
, HasCallStack
)
=> exa
-> IndigoM ()
-> IndigoM ()
whenNone :: forall x exa.
(KnownValue x, exa :~> Maybe x, HasCallStack) =>
exa -> IndigoM () -> IndigoM ()
whenNone exa
c IndigoM ()
f = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ exa -> (Var x -> IndigoM ()) -> IndigoM () -> IndigoFunction ()
forall x a b ex.
(KnownValue x, ex :~> Maybe x, IfConstraint a b, HasCallStack) =>
ex -> (Var x -> IndigoM a) -> IndigoM b -> IndigoM (RetVars a)
ifSome exa
c (\Var x
_ -> () -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()) IndigoM ()
f
ifRight
:: forall x y a b ex .
( KnownValue x
, KnownValue y
, ex :~> Either y x
, IfConstraint a b
, HasCallStack
)
=> ex
-> (Var x -> IndigoM a)
-> (Var y -> IndigoM b)
-> IndigoM (RetVars a)
ifRight :: forall x y a b ex.
(KnownValue x, KnownValue y, ex :~> Either y x, IfConstraint a b,
HasCallStack) =>
ex
-> (Var x -> IndigoM a)
-> (Var y -> IndigoM b)
-> IndigoM (RetVars a)
ifRight ex
ex Var x -> IndigoM a
rb Var y -> IndigoM b
lb = IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars b) -> IndigoM (RetVars b))
-> IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars b) -> IndigoM (RetVars b))
-> StatementF IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a b. (a -> b) -> a -> b
$ Expr (Either y x)
-> (Var x -> IndigoM a)
-> (Var y -> IndigoM b)
-> StatementF IndigoM (RetVars a)
forall a1 b x y (freer :: * -> *).
(IfConstraint a1 b, KnownValue x, KnownValue y) =>
Expr (Either y x)
-> (Var x -> freer a1)
-> (Var y -> freer b)
-> StatementF freer (RetVars' (ClassifyReturnValue a1) a1)
IfRight (ex -> Expr (ExprType ex)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex
ex) Var x -> IndigoM a
rb Var y -> IndigoM b
lb
ifLeft
:: forall x y a b ex .
( KnownValue x
, KnownValue y
, ex :~> Either y x
, IfConstraint a b
, HasCallStack
)
=> ex
-> (Var y -> IndigoM b)
-> (Var x -> IndigoM a)
-> IndigoM (RetVars a)
ifLeft :: forall x y a b ex.
(KnownValue x, KnownValue y, ex :~> Either y x, IfConstraint a b,
HasCallStack) =>
ex
-> (Var y -> IndigoM b)
-> (Var x -> IndigoM a)
-> IndigoM (RetVars a)
ifLeft ex
ex Var y -> IndigoM b
lb Var x -> IndigoM a
rb = IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars b) -> IndigoM (RetVars b))
-> IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a b. (a -> b) -> a -> b
$ ex
-> (Var x -> IndigoM a)
-> (Var y -> IndigoM b)
-> IndigoM (RetVars a)
forall x y a b ex.
(KnownValue x, KnownValue y, ex :~> Either y x, IfConstraint a b,
HasCallStack) =>
ex
-> (Var x -> IndigoM a)
-> (Var y -> IndigoM b)
-> IndigoM (RetVars a)
ifRight ex
ex Var x -> IndigoM a
rb Var y -> IndigoM b
lb
whenRight
:: forall x y ex .
( KnownValue x
, KnownValue y
, ex :~> Either y x
, HasCallStack
)
=> ex
-> (Var x -> IndigoM ())
-> IndigoM ()
whenRight :: forall x y ex.
(KnownValue x, KnownValue y, ex :~> Either y x, HasCallStack) =>
ex -> (Var x -> IndigoM ()) -> IndigoM ()
whenRight ex
c Var x -> IndigoM ()
f = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ ex
-> (Var x -> IndigoM ())
-> (Var y -> IndigoM ())
-> IndigoFunction ()
forall x y a b ex.
(KnownValue x, KnownValue y, ex :~> Either y x, IfConstraint a b,
HasCallStack) =>
ex
-> (Var x -> IndigoM a)
-> (Var y -> IndigoM b)
-> IndigoM (RetVars a)
ifRight ex
c Var x -> IndigoM ()
f (\Var y
_ -> () -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
whenLeft
:: forall x y ex .
( KnownValue x
, KnownValue y
, ex :~> Either y x
, HasCallStack
)
=> ex
-> (Var y -> IndigoM ())
-> IndigoM ()
whenLeft :: forall x y ex.
(KnownValue x, KnownValue y, ex :~> Either y x, HasCallStack) =>
ex -> (Var y -> IndigoM ()) -> IndigoM ()
whenLeft ex
c Var y -> IndigoM ()
f = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ ex
-> (Var x -> IndigoM ())
-> (Var y -> IndigoM ())
-> IndigoFunction ()
forall x y a b ex.
(KnownValue x, KnownValue y, ex :~> Either y x, IfConstraint a b,
HasCallStack) =>
ex
-> (Var x -> IndigoM a)
-> (Var y -> IndigoM b)
-> IndigoM (RetVars a)
ifRight ex
c (\Var x
_ -> () -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()) Var y -> IndigoM ()
f
ifCons
:: forall x a b ex . (KnownValue x, ex :~> List x, IfConstraint a b, HasCallStack)
=> ex
-> (Var x -> Var (List x) -> IndigoM a)
-> IndigoM b
-> IndigoM (RetVars a)
ifCons :: forall x a b ex.
(KnownValue x, ex :~> List x, IfConstraint a b, HasCallStack) =>
ex
-> (Var x -> Var (List x) -> IndigoM a)
-> IndigoM b
-> IndigoM (RetVars a)
ifCons ex
ex Var x -> Var (List x) -> IndigoM a
tb IndigoM b
fb = IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars b) -> IndigoM (RetVars b))
-> IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars b) -> IndigoM (RetVars b))
-> StatementF IndigoM (RetVars b) -> IndigoM (RetVars b)
forall a b. (a -> b) -> a -> b
$ Expr (List x)
-> (Var x -> Var (List x) -> IndigoM a)
-> IndigoM b
-> StatementF IndigoM (RetVars a)
forall a1 b x (freer :: * -> *).
(IfConstraint a1 b, KnownValue x) =>
Expr (List x)
-> (Var x -> Var (List x) -> freer a1)
-> freer b
-> StatementF freer (RetVars' (ClassifyReturnValue a1) a1)
IfCons (ex -> Expr (ExprType ex)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex
ex) Var x -> Var (List x) -> IndigoM a
tb IndigoM b
fb
caseRec
:: forall dt guard ret clauses .
( CaseCommonF (IndigoMCaseClauseL IndigoM) dt ret clauses
, guard :~> dt
, HasCallStack
)
=> guard
-> clauses
-> IndigoM (RetVars ret)
caseRec :: forall dt guard ret clauses.
(CaseCommonF (IndigoMCaseClauseL IndigoM) dt ret clauses,
guard :~> dt, HasCallStack) =>
guard -> clauses -> IndigoM (RetVars ret)
caseRec guard
g = IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (clauses -> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> clauses
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (clauses
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> clauses
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr dt
-> clauses
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall (freer :: * -> *) dt ret clauses.
CaseCommonF (IndigoMCaseClauseL freer) dt ret clauses =>
Expr dt
-> clauses
-> StatementF freer (RetVars' (ClassifyReturnValue ret) ret)
Case (guard -> Expr (ExprType guard)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr guard
g)
case_
:: forall dt guard ret clauses.
( CaseCommonF (IndigoMCaseClauseL IndigoM) dt ret clauses
, RecFromTuple clauses
, guard :~> dt
, HasCallStack
)
=> guard
-> IsoRecTuple clauses
-> IndigoM (RetVars ret)
case_ :: forall dt guard ret clauses.
(CaseCommonF (IndigoMCaseClauseL IndigoM) dt ret clauses,
RecFromTuple clauses, guard :~> dt, HasCallStack) =>
guard -> IsoRecTuple clauses -> IndigoM (RetVars ret)
case_ guard
g = IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses dt))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses dt))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr dt
-> clauses -> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall dt guard ret clauses.
(CaseCommonF (IndigoMCaseClauseL IndigoM) dt ret clauses,
guard :~> dt, HasCallStack) =>
guard -> clauses -> IndigoM (RetVars ret)
caseRec (guard -> Expr (ExprType guard)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr guard
g) (clauses -> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses dt))
-> clauses)
-> IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses dt))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall r. RecFromTuple r => IsoRecTuple r -> r
recFromTuple @clauses
entryCaseRec
:: forall dt entrypointKind guard ret clauses .
( CaseCommonF (IndigoMCaseClauseL IndigoM) dt ret clauses
, DocumentEntrypoints entrypointKind dt
, guard :~> dt
, HasCallStack
)
=> Proxy entrypointKind
-> guard
-> clauses
-> IndigoM (RetVars ret)
entryCaseRec :: forall dt entrypointKind guard ret clauses.
(CaseCommonF (IndigoMCaseClauseL IndigoM) dt ret clauses,
DocumentEntrypoints entrypointKind dt, guard :~> dt,
HasCallStack) =>
Proxy entrypointKind -> guard -> clauses -> IndigoM (RetVars ret)
entryCaseRec Proxy entrypointKind
proxy guard
g clauses
cls = IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a b. (a -> b) -> a -> b
$ Proxy entrypointKind
-> Expr dt
-> clauses
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall (freer :: * -> *) dt ret clauses entrypointKind.
(CaseCommonF (IndigoMCaseClauseL freer) dt ret clauses,
DocumentEntrypoints entrypointKind dt) =>
Proxy entrypointKind
-> Expr dt
-> clauses
-> StatementF freer (RetVars' (ClassifyReturnValue ret) ret)
EntryCase Proxy entrypointKind
proxy (guard -> Expr (ExprType guard)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr guard
g) clauses
cls
entryCase
:: forall dt entrypointKind guard ret clauses .
( CaseCommonF (IndigoMCaseClauseL IndigoM) dt ret clauses
, RecFromTuple clauses
, DocumentEntrypoints entrypointKind dt
, guard :~> dt
, HasCallStack
)
=> Proxy entrypointKind
-> guard
-> IsoRecTuple clauses
-> IndigoM (RetVars ret)
entryCase :: forall dt entrypointKind guard ret clauses.
(CaseCommonF (IndigoMCaseClauseL IndigoM) dt ret clauses,
RecFromTuple clauses, DocumentEntrypoints entrypointKind dt,
guard :~> dt, HasCallStack) =>
Proxy entrypointKind
-> guard -> IsoRecTuple clauses -> IndigoM (RetVars ret)
entryCase Proxy entrypointKind
proxy guard
g = IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses dt))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses dt))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy entrypointKind
-> guard
-> clauses
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall dt entrypointKind guard ret clauses.
(CaseCommonF (IndigoMCaseClauseL IndigoM) dt ret clauses,
DocumentEntrypoints entrypointKind dt, guard :~> dt,
HasCallStack) =>
Proxy entrypointKind -> guard -> clauses -> IndigoM (RetVars ret)
entryCaseRec Proxy entrypointKind
proxy guard
g (clauses -> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses dt))
-> clauses)
-> IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses dt))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall r. RecFromTuple r => IsoRecTuple r -> r
recFromTuple @clauses
entryCaseSimple
:: forall cp guard ret clauses .
( CaseCommonF (IndigoMCaseClauseL IndigoM) cp ret clauses
, RecFromTuple clauses
, DocumentEntrypoints PlainEntrypointsKind cp
, NiceParameterFull cp
, RequireFlatParamEps cp
, guard :~> cp
, HasCallStack
)
=> guard
-> IsoRecTuple clauses
-> IndigoM (RetVars ret)
entryCaseSimple :: forall cp guard ret clauses.
(CaseCommonF (IndigoMCaseClauseL IndigoM) cp ret clauses,
RecFromTuple clauses, DocumentEntrypoints PlainEntrypointsKind cp,
NiceParameterFull cp, RequireFlatParamEps cp, guard :~> cp,
HasCallStack) =>
guard -> IsoRecTuple clauses -> IndigoM (RetVars ret)
entryCaseSimple guard
g = IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses cp))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses cp))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses cp))
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses cp))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr cp
-> clauses
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall (freer :: * -> *) cp ret clauses.
(CaseCommonF (IndigoMCaseClauseL freer) cp ret clauses,
DocumentEntrypoints PlainEntrypointsKind cp, NiceParameterFull cp,
RequireFlatParamEps cp) =>
Expr cp
-> clauses
-> StatementF freer (RetVars' (ClassifyReturnValue ret) ret)
EntryCaseSimple (guard -> Expr (ExprType guard)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr guard
g) (clauses
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses cp))
-> clauses)
-> IsoRecTuple
(Rec (IndigoMCaseClauseL IndigoM ret) (CaseClauses cp))
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall r. RecFromTuple r => IsoRecTuple r -> r
recFromTuple @clauses
{-# DEPRECATED (//->) "use '#=' instead" #-}
(//->)
:: ( name ~ (AppendSymbol "c" ctor)
, KnownValue x
, ScopeCodeGen retBr
, ret ~ RetExprs retBr
, RetOutStack ret ~ RetOutStack retBr
)
=> Label name
-> (Var x -> IndigoM retBr)
-> IndigoMCaseClauseL IndigoM ret ('CaseClauseParam ctor ('OneField x))
//-> :: forall (name :: Symbol) (ctor :: Symbol) x retBr ret.
(name ~ AppendSymbol "c" ctor, KnownValue x, ScopeCodeGen retBr,
ret ~ RetExprs retBr, RetOutStack ret ~ RetOutStack retBr) =>
Label name
-> (Var x -> IndigoM retBr)
-> IndigoMCaseClauseL
IndigoM ret ('CaseClauseParam ctor ('OneField x))
(//->) Label name
cName Var x -> IndigoM retBr
b = Label name
-> (Var x -> IndigoM retBr)
-> IndigoMCaseClauseL
IndigoM ret ('CaseClauseParam ctor ('OneField x))
forall (name :: Symbol) (ctor :: Symbol) x retBr ret
(freer :: * -> *).
(name ~ AppendSymbol "c" ctor, KnownValue x, ScopeCodeGen retBr,
ret ~ RetExprs retBr, RetOutStack ret ~ RetOutStack retBr) =>
Label name
-> (Var x -> freer retBr)
-> IndigoMCaseClauseL
freer ret ('CaseClauseParam ctor ('OneField x))
OneFieldIndigoMCaseClauseL Label name
cName Var x -> IndigoM retBr
b
infixr 0 //->
(#=)
:: ( name ~ (AppendSymbol "c" ctor)
, KnownValue x
, ScopeCodeGen retBr
, ret ~ RetExprs retBr
, RetOutStack ret ~ RetOutStack retBr
)
=> Label name
-> (Var x -> IndigoM retBr)
-> IndigoMCaseClauseL IndigoM ret ('CaseClauseParam ctor ('OneField x))
#= :: forall (name :: Symbol) (ctor :: Symbol) x retBr ret.
(name ~ AppendSymbol "c" ctor, KnownValue x, ScopeCodeGen retBr,
ret ~ RetExprs retBr, RetOutStack ret ~ RetOutStack retBr) =>
Label name
-> (Var x -> IndigoM retBr)
-> IndigoMCaseClauseL
IndigoM ret ('CaseClauseParam ctor ('OneField x))
(#=) Label name
cName Var x -> IndigoM retBr
b = Label name
-> (Var x -> IndigoM retBr)
-> IndigoMCaseClauseL
IndigoM ret ('CaseClauseParam ctor ('OneField x))
forall (name :: Symbol) (ctor :: Symbol) x retBr ret
(freer :: * -> *).
(name ~ AppendSymbol "c" ctor, KnownValue x, ScopeCodeGen retBr,
ret ~ RetExprs retBr, RetOutStack ret ~ RetOutStack retBr) =>
Label name
-> (Var x -> freer retBr)
-> IndigoMCaseClauseL
freer ret ('CaseClauseParam ctor ('OneField x))
OneFieldIndigoMCaseClauseL Label name
cName Var x -> IndigoM retBr
b
infixr 0 #=
type IndigoFunction ret = IndigoM (RetVars ret)
type IndigoProcedure = IndigoM ()
type IndigoEntrypoint param = param -> IndigoProcedure
scope
:: forall a . (ScopeCodeGen a, HasCallStack)
=> IndigoM a
-> IndigoFunction a
scope :: forall a.
(ScopeCodeGen a, HasCallStack) =>
IndigoM a -> IndigoFunction a
scope = IndigoM (RetVars' (ClassifyReturnValue a) a)
-> IndigoM (RetVars' (ClassifyReturnValue a) a)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue a) a)
-> IndigoM (RetVars' (ClassifyReturnValue a) a))
-> (IndigoM a -> IndigoM (RetVars' (ClassifyReturnValue a) a))
-> IndigoM a
-> IndigoM (RetVars' (ClassifyReturnValue a) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM (RetVars' (ClassifyReturnValue a) a)
-> IndigoM (RetVars' (ClassifyReturnValue a) a)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars' (ClassifyReturnValue a) a)
-> IndigoM (RetVars' (ClassifyReturnValue a) a))
-> (IndigoM a
-> StatementF IndigoM (RetVars' (ClassifyReturnValue a) a))
-> IndigoM a
-> IndigoM (RetVars' (ClassifyReturnValue a) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IndigoM a
-> StatementF IndigoM (RetVars' (ClassifyReturnValue a) a)
forall a1 (freer :: * -> *).
ScopeCodeGen a1 =>
freer a1 -> StatementF freer (RetVars' (ClassifyReturnValue a1) a1)
Scope
defFunction
:: forall a . (ScopeCodeGen a, HasCallStack)
=> IndigoM a
-> IndigoFunction a
defFunction :: forall a.
(ScopeCodeGen a, HasCallStack) =>
IndigoM a -> IndigoFunction a
defFunction = IndigoM (RetVars' (ClassifyReturnValue a) a)
-> IndigoM (RetVars' (ClassifyReturnValue a) a)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue a) a)
-> IndigoM (RetVars' (ClassifyReturnValue a) a))
-> (IndigoM a -> IndigoM (RetVars' (ClassifyReturnValue a) a))
-> IndigoM a
-> IndigoM (RetVars' (ClassifyReturnValue a) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IndigoM a -> IndigoM (RetVars' (ClassifyReturnValue a) a)
forall a.
(ScopeCodeGen a, HasCallStack) =>
IndigoM a -> IndigoFunction a
scope
defContract
:: HasCallStack
=> ((HasSideEffects, IsNotInView) => IndigoM ())
-> ((HasSideEffects, IsNotInView) => IndigoProcedure)
defContract :: HasCallStack =>
((HasSideEffects, IsNotInView) => IndigoM ())
-> (HasSideEffects, IsNotInView) => IndigoM ()
defContract (HasSideEffects, IsNotInView) => IndigoM ()
c = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoFunction ()
forall a.
(ScopeCodeGen a, HasCallStack) =>
IndigoM a -> IndigoFunction a
scope IndigoM ()
(HasSideEffects, IsNotInView) => IndigoM ()
c)
defNamedEffLambda1
:: forall st argExpr res .
( ToExpr argExpr
, Typeable res
, ExecuteLambdaEff1C st (ExprType argExpr) res
, CreateLambdaEff1C st (ExprType argExpr) res
, HasCallStack
)
=> String
-> (Var (ExprType argExpr) -> IndigoM res)
-> (argExpr -> IndigoM (RetVars res))
defNamedEffLambda1 :: forall st argExpr res.
(ToExpr argExpr, Typeable res,
ExecuteLambdaEff1C st (ExprType argExpr) res,
CreateLambdaEff1C st (ExprType argExpr) res, HasCallStack) =>
[Char]
-> (Var (ExprType argExpr) -> IndigoM res)
-> argExpr
-> IndigoM (RetVars res)
defNamedEffLambda1 [Char]
lName Var (ExprType argExpr) -> IndigoM res
body = \argExpr
ex ->
IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars res) -> IndigoM (RetVars res))
-> IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars res) -> IndigoM (RetVars res))
-> StatementF IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a b. (a -> b) -> a -> b
$ LambdaKind st (ExprType argExpr) res '[st, Ops]
-> [Char]
-> (Var (ExprType argExpr) -> IndigoM res)
-> Expr (ExprType argExpr)
-> StatementF IndigoM (RetVars res)
forall st arg res (extra :: [*]) (freer :: * -> *).
LambdaKind st arg res extra
-> [Char]
-> (Var arg -> freer res)
-> Expr arg
-> StatementF freer (RetVars' (ClassifyReturnValue res) res)
LambdaCall1 (Proxy st -> LambdaKind st (ExprType argExpr) res '[st, Ops]
forall st arg res.
(ExecuteLambdaEff1C st arg res,
CreateLambda1CGeneric '[st, Ops] arg res, Typeable res) =>
Proxy st -> LambdaKind st arg res '[st, Ops]
EffLambda (forall {t}. Proxy t
forall {k} (t :: k). Proxy t
Proxy @st)) [Char]
lName Var (ExprType argExpr) -> IndigoM res
body (argExpr -> Expr (ExprType argExpr)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr argExpr
ex)
defNamedLambda1
:: forall st argExpr res .
( ToExpr argExpr
, Typeable res
, ExecuteLambda1C st (ExprType argExpr) res
, CreateLambda1C st (ExprType argExpr) res
, HasCallStack
)
=> String
-> (Var (ExprType argExpr) -> IndigoM res)
-> (argExpr -> IndigoM (RetVars res))
defNamedLambda1 :: forall st argExpr res.
(ToExpr argExpr, Typeable res,
ExecuteLambda1C st (ExprType argExpr) res,
CreateLambda1C st (ExprType argExpr) res, HasCallStack) =>
[Char]
-> (Var (ExprType argExpr) -> IndigoM res)
-> argExpr
-> IndigoM (RetVars res)
defNamedLambda1 [Char]
lName Var (ExprType argExpr) -> IndigoM res
body = \argExpr
ex ->
IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars res) -> IndigoM (RetVars res))
-> IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars res) -> IndigoM (RetVars res))
-> StatementF IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a b. (a -> b) -> a -> b
$ LambdaKind st (ExprType argExpr) res '[st]
-> [Char]
-> (Var (ExprType argExpr) -> IndigoM res)
-> Expr (ExprType argExpr)
-> StatementF IndigoM (RetVars res)
forall st arg res (extra :: [*]) (freer :: * -> *).
LambdaKind st arg res extra
-> [Char]
-> (Var arg -> freer res)
-> Expr arg
-> StatementF freer (RetVars' (ClassifyReturnValue res) res)
LambdaCall1 (Proxy st -> LambdaKind st (ExprType argExpr) res '[st]
forall st arg res.
(ExecuteLambda1C st arg res, CreateLambda1CGeneric '[st] arg res,
Typeable res) =>
Proxy st -> LambdaKind st arg res '[st]
StorageLambda (forall {t}. Proxy t
forall {k} (t :: k). Proxy t
Proxy @st)) [Char]
lName Var (ExprType argExpr) -> IndigoM res
body (argExpr -> Expr (ExprType argExpr)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr argExpr
ex)
defNamedLambda0
:: forall st res .
( Typeable res
, ExecuteLambda1C st () res
, CreateLambda1C st () res
, HasCallStack
)
=> String
-> IndigoM res
-> IndigoM (RetVars res)
defNamedLambda0 :: forall st res.
(Typeable res, ExecuteLambda1C st () res, CreateLambda1C st () res,
HasCallStack) =>
[Char] -> IndigoM res -> IndigoM (RetVars res)
defNamedLambda0 [Char]
lName IndigoM res
body =
IndigoM (RetVars' (ClassifyReturnValue res) res)
-> IndigoM (RetVars' (ClassifyReturnValue res) res)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue res) res)
-> IndigoM (RetVars' (ClassifyReturnValue res) res))
-> IndigoM (RetVars' (ClassifyReturnValue res) res)
-> IndigoM (RetVars' (ClassifyReturnValue res) res)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars' (ClassifyReturnValue res) res)
-> IndigoM (RetVars' (ClassifyReturnValue res) res)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars' (ClassifyReturnValue res) res)
-> IndigoM (RetVars' (ClassifyReturnValue res) res))
-> StatementF IndigoM (RetVars' (ClassifyReturnValue res) res)
-> IndigoM (RetVars' (ClassifyReturnValue res) res)
forall a b. (a -> b) -> a -> b
$ LambdaKind st () res '[st]
-> [Char]
-> (Var () -> IndigoM res)
-> Expr ()
-> StatementF IndigoM (RetVars' (ClassifyReturnValue res) res)
forall st arg res (extra :: [*]) (freer :: * -> *).
LambdaKind st arg res extra
-> [Char]
-> (Var arg -> freer res)
-> Expr arg
-> StatementF freer (RetVars' (ClassifyReturnValue res) res)
LambdaCall1 (Proxy st -> LambdaKind st () res '[st]
forall st arg res.
(ExecuteLambda1C st arg res, CreateLambda1CGeneric '[st] arg res,
Typeable res) =>
Proxy st -> LambdaKind st arg res '[st]
StorageLambda (forall {t}. Proxy t
forall {k} (t :: k). Proxy t
Proxy @st)) [Char]
lName (\(Var ()
_ :: Var ()) -> IndigoM res
body) (() -> Expr ()
forall a. NiceConstant a => a -> Expr a
C ())
defNamedPureLambda1
:: forall argExpr res .
( ToExpr argExpr
, Typeable res
, ExecuteLambdaPure1C (ExprType argExpr) res
, CreateLambdaPure1C (ExprType argExpr) res
, HasCallStack
)
=> String
-> (Var (ExprType argExpr) -> IndigoM res)
-> (argExpr -> IndigoM (RetVars res))
defNamedPureLambda1 :: forall argExpr res.
(ToExpr argExpr, Typeable res,
ExecuteLambdaPure1C (ExprType argExpr) res,
CreateLambdaPure1C (ExprType argExpr) res, HasCallStack) =>
[Char]
-> (Var (ExprType argExpr) -> IndigoM res)
-> argExpr
-> IndigoM (RetVars res)
defNamedPureLambda1 [Char]
lName Var (ExprType argExpr) -> IndigoM res
body = \argExpr
ex ->
IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars res) -> IndigoM (RetVars res))
-> IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars res) -> IndigoM (RetVars res))
-> StatementF IndigoM (RetVars res) -> IndigoM (RetVars res)
forall a b. (a -> b) -> a -> b
$ LambdaKind Any (ExprType argExpr) res '[]
-> [Char]
-> (Var (ExprType argExpr) -> IndigoM res)
-> Expr (ExprType argExpr)
-> StatementF IndigoM (RetVars res)
forall st arg res (extra :: [*]) (freer :: * -> *).
LambdaKind st arg res extra
-> [Char]
-> (Var arg -> freer res)
-> Expr arg
-> StatementF freer (RetVars' (ClassifyReturnValue res) res)
LambdaCall1 LambdaKind Any (ExprType argExpr) res '[]
forall arg res st.
(ExecuteLambdaPure1C arg res, CreateLambda1CGeneric '[] arg res,
Typeable res) =>
LambdaKind st arg res '[]
PureLambda [Char]
lName Var (ExprType argExpr) -> IndigoM res
body (argExpr -> Expr (ExprType argExpr)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr argExpr
ex)
while :: forall ex . (ex :~> Bool, HasCallStack) => ex -> IndigoM () -> IndigoM ()
while :: forall exc.
(exc :~> Bool, HasCallStack) =>
exc -> IndigoM () -> IndigoM ()
while ex
e IndigoM ()
body = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM () -> IndigoM ()
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM () -> IndigoM ())
-> StatementF IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ Expr Bool -> IndigoM () -> StatementF IndigoM ()
forall (freer :: * -> *).
Expr Bool -> freer () -> StatementF freer ()
While (ex -> Expr (ExprType ex)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex
e) IndigoM ()
body
whileLeft
:: forall x y ex .
( ex :~> Either y x
, KnownValue y
, KnownValue x
, HasCallStack
)
=> ex
-> (Var y -> IndigoM ())
-> IndigoM (Var x)
whileLeft :: forall x y ex.
(ex :~> Either y x, KnownValue y, KnownValue x, HasCallStack) =>
ex -> (Var y -> IndigoM ()) -> IndigoM (Var x)
whileLeft ex
e Var y -> IndigoM ()
body = IndigoM (Var x) -> IndigoM (Var x)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (Var x) -> IndigoM (Var x))
-> IndigoM (Var x) -> IndigoM (Var x)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (Var x) -> IndigoM (Var x)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (Var x) -> IndigoM (Var x))
-> StatementF IndigoM (Var x) -> IndigoM (Var x)
forall a b. (a -> b) -> a -> b
$ Expr (Either y x)
-> (Var y -> IndigoM ()) -> StatementF IndigoM (Var x)
forall x y (freer :: * -> *).
(KnownValue x, KnownValue y) =>
Expr (Either y x)
-> (Var y -> freer ()) -> StatementF freer (Var x)
WhileLeft (ex -> Expr (ExprType ex)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex
e) Var y -> IndigoM ()
body
forEach
:: forall a e . (IterOpHs a, KnownValue (IterOpElHs a), e :~> a, HasCallStack)
=> e -> (Var (IterOpElHs a) -> IndigoM ())
-> IndigoM ()
forEach :: forall a e.
(IterOpHs a, KnownValue (IterOpElHs a), e :~> a, HasCallStack) =>
e -> (Var (IterOpElHs a) -> IndigoM ()) -> IndigoM ()
forEach e
container Var (IterOpElHs a) -> IndigoM ()
body = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM () -> IndigoM ()
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM () -> IndigoM ())
-> StatementF IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ Expr a
-> (Var (IterOpElHs a) -> IndigoM ()) -> StatementF IndigoM ()
forall a1 (freer :: * -> *).
(IterOpHs a1, KnownValue (IterOpElHs a1)) =>
Expr a1 -> (Var (IterOpElHs a1) -> freer ()) -> StatementF freer ()
ForEach (e -> Expr (ExprType e)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr e
container) Var (IterOpElHs a) -> IndigoM ()
body
doc :: (DocItem di, HasCallStack) => di -> IndigoM ()
doc :: forall di. (DocItem di, HasCallStack) => di -> IndigoM ()
doc di
di = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ (forall (inp :: [*]). SomeIndigoState inp) -> IndigoM ()
liftIndigoState ((forall (inp :: [*]). SomeIndigoState inp) -> IndigoM ())
-> (forall (inp :: [*]). SomeIndigoState inp) -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ IndigoState inp inp -> SomeIndigoState inp
forall (inp :: [*]) (out :: [*]).
IndigoState inp out -> SomeIndigoState inp
toSIS (IndigoState inp inp -> SomeIndigoState inp)
-> IndigoState inp inp -> SomeIndigoState inp
forall a b. (a -> b) -> a -> b
$ di -> IndigoState inp inp
forall di (s :: [*]). DocItem di => di -> IndigoState s s
B.doc di
di
docGroup :: (DocItem di, HasCallStack) => (SubDoc -> di) -> IndigoM () -> IndigoM ()
docGroup :: forall di.
(DocItem di, HasCallStack) =>
(SubDoc -> di) -> IndigoM () -> IndigoM ()
docGroup SubDoc -> di
f IndigoM ()
i = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM () -> IndigoM ()
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM () -> IndigoM ())
-> StatementF IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ (SubDoc -> di) -> IndigoM () -> StatementF IndigoM ()
forall di (freer :: * -> *).
DocItem di =>
(SubDoc -> di) -> freer () -> StatementF freer ()
DocGroup SubDoc -> di
f IndigoM ()
i
{-# DEPRECATED docStorage "Use `doc (dStorage @storage)` instead." #-}
docStorage :: forall storage. (TypeHasDoc storage, HasCallStack) => IndigoM ()
docStorage :: forall storage. (TypeHasDoc storage, HasCallStack) => IndigoM ()
docStorage = DStorageType -> IndigoM ()
forall di. (DocItem di, HasCallStack) => di -> IndigoM ()
doc (DStorageType -> IndigoM ()) -> DStorageType -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ forall store. TypeHasDoc store => DStorageType
dStorage @storage
{-# DEPRECATED contractName "Use `docGroup name` instead." #-}
contractName :: HasCallStack => Text -> IndigoM () -> IndigoM ()
contractName :: HasCallStack => Text -> IndigoM () -> IndigoM ()
contractName = (SubDoc -> DName) -> IndigoM () -> IndigoM ()
forall di.
(DocItem di, HasCallStack) =>
(SubDoc -> di) -> IndigoM () -> IndigoM ()
docGroup ((SubDoc -> DName) -> IndigoM () -> IndigoM ())
-> (Text -> SubDoc -> DName) -> Text -> IndigoM () -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> SubDoc -> DName
DName
{-# DEPRECATED contractGeneral "Use `docGroup DGeneralInfoSection` instead." #-}
contractGeneral :: HasCallStack => IndigoM () -> IndigoM ()
contractGeneral :: HasCallStack => IndigoM () -> IndigoM ()
contractGeneral = (SubDoc -> DGeneralInfoSection) -> IndigoM () -> IndigoM ()
forall di.
(DocItem di, HasCallStack) =>
(SubDoc -> di) -> IndigoM () -> IndigoM ()
docGroup SubDoc -> DGeneralInfoSection
DGeneralInfoSection
contractGeneralDefault :: HasCallStack => IndigoM ()
contractGeneralDefault :: HasCallStack => IndigoM ()
contractGeneralDefault = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ (forall (inp :: [*]). SomeIndigoState inp) -> IndigoM ()
liftIndigoState ((forall (inp :: [*]). SomeIndigoState inp) -> IndigoM ())
-> (forall (inp :: [*]). SomeIndigoState inp) -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ IndigoState inp inp -> SomeIndigoState inp
forall (inp :: [*]) (out :: [*]).
IndigoState inp out -> SomeIndigoState inp
toSIS (IndigoState inp inp -> SomeIndigoState inp)
-> IndigoState inp inp -> SomeIndigoState inp
forall a b. (a -> b) -> a -> b
$ IndigoState inp inp
forall (s :: [*]). IndigoState s s
B.contractGeneralDefault
finalizeParamCallingDoc
:: forall param.
( ToExpr param
, NiceParameterFull (ExprType param)
, RequireSumType (ExprType param)
, HasCallStack
)
=> (Var (ExprType param) -> IndigoM ()) -> param -> IndigoM ()
finalizeParamCallingDoc :: forall param.
(ToExpr param, NiceParameterFull (ExprType param),
RequireSumType (ExprType param), HasCallStack) =>
(Var (ExprType param) -> IndigoM ()) -> param -> IndigoM ()
finalizeParamCallingDoc Var (ExprType param) -> IndigoM ()
i = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (param -> IndigoM ()) -> param -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM () -> IndigoM ()
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM () -> IndigoM ())
-> (param -> StatementF IndigoM ()) -> param -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Var (ExprType param) -> IndigoM ())
-> Expr (ExprType param) -> StatementF IndigoM ()
forall cp (freer :: * -> *).
(NiceParameterFull cp, RequireSumType cp, HasCallStack) =>
(Var cp -> freer ()) -> Expr cp -> StatementF freer ()
FinalizeParamCallingDoc Var (ExprType param) -> IndigoM ()
i (Expr (ExprType param) -> StatementF IndigoM ())
-> (param -> Expr (ExprType param))
-> param
-> StatementF IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. param -> Expr (ExprType param)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr
description :: HasCallStack => Markdown -> IndigoM ()
description :: HasCallStack => Markdown -> IndigoM ()
description = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (Markdown -> IndigoM ()) -> Markdown -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DDescription -> IndigoM ()
forall di. (DocItem di, HasCallStack) => di -> IndigoM ()
doc (DDescription -> IndigoM ())
-> (Markdown -> DDescription) -> Markdown -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Markdown -> DDescription
DDescription
anchor :: HasCallStack => Text -> IndigoM ()
anchor :: HasCallStack => Text -> IndigoM ()
anchor = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (Text -> IndigoM ()) -> Text -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DAnchor -> IndigoM ()
forall di. (DocItem di, HasCallStack) => di -> IndigoM ()
doc (DAnchor -> IndigoM ()) -> (Text -> DAnchor) -> Text -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Anchor -> DAnchor
DAnchor (Anchor -> DAnchor) -> (Text -> Anchor) -> Text -> DAnchor
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Anchor
forall anchor. ToAnchor anchor => anchor -> Anchor
toAnchor
example :: forall a. (NiceParameter a, HasCallStack) => a -> IndigoM ()
example :: forall a. (NiceParameter a, HasCallStack) => a -> IndigoM ()
example = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> (a -> IndigoM ()) -> a -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DEntrypointExample -> IndigoM ()
forall di. (DocItem di, HasCallStack) => di -> IndigoM ()
doc (DEntrypointExample -> IndigoM ())
-> (a -> DEntrypointExample) -> a -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> DEntrypointExample
forall a. NiceParameter a => a -> DEntrypointExample
mkDEntrypointExample
selfCalling
:: forall p mname.
( NiceParameterFull p
, KnownValue (GetEntrypointArgCustom p mname)
, IsoValue (ContractRef (GetEntrypointArgCustom p mname))
, HasCallStack, IsNotInView
)
=> EntrypointRef mname
-> IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
selfCalling :: forall p (mname :: Maybe Symbol).
(NiceParameterFull p, KnownValue (GetEntrypointArgCustom p mname),
IsoValue (ContractRef (GetEntrypointArgCustom p mname)),
HasCallStack, IsNotInView) =>
EntrypointRef mname
-> IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
selfCalling EntrypointRef mname
ep = IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
-> IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
-> IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname))))
-> IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
-> IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
forall a b. (a -> b) -> a -> b
$ StatementF
IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
-> IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF
IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
-> IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname))))
-> StatementF
IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
-> IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
forall a b. (a -> b) -> a -> b
$ Proxy p
-> EntrypointRef mname
-> StatementF
IndigoM (Var (ContractRef (GetEntrypointArgCustom p mname)))
forall p (mname :: Maybe Symbol) (freer :: * -> *).
(NiceParameterFull p, KnownValue (GetEntrypointArgCustom p mname),
IsoValue (ContractRef (GetEntrypointArgCustom p mname)),
IsNotInView) =>
Proxy p
-> EntrypointRef mname
-> StatementF
freer (Var (ContractRef (GetEntrypointArgCustom p mname)))
SelfCalling (forall {t}. Proxy t
forall {k} (t :: k). Proxy t
Proxy @p) EntrypointRef mname
ep
contractCalling
:: forall cp vd epRef epArg addr exAddr.
( HasEntrypointArg cp epRef epArg
, ToTAddress cp vd addr
, ToT addr ~ ToT Address
, exAddr :~> addr
, KnownValue epArg
, IsoValue (ContractRef epArg)
, HasCallStack
)
=> epRef -> exAddr -> IndigoM (Var (Maybe (ContractRef epArg)))
contractCalling :: forall cp vd epRef epArg addr exAddr.
(HasEntrypointArg cp epRef epArg, ToTAddress cp vd addr,
ToT addr ~ ToT Address, exAddr :~> addr, KnownValue epArg,
IsoValue (ContractRef epArg), HasCallStack) =>
epRef -> exAddr -> IndigoM (Var (Maybe (ContractRef epArg)))
contractCalling epRef
epRef = IndigoM (Var (Maybe (ContractRef epArg)))
-> IndigoM (Var (Maybe (ContractRef epArg)))
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (Var (Maybe (ContractRef epArg)))
-> IndigoM (Var (Maybe (ContractRef epArg))))
-> (exAddr -> IndigoM (Var (Maybe (ContractRef epArg))))
-> exAddr
-> IndigoM (Var (Maybe (ContractRef epArg)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM (Var (Maybe (ContractRef epArg)))
-> IndigoM (Var (Maybe (ContractRef epArg)))
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (Var (Maybe (ContractRef epArg)))
-> IndigoM (Var (Maybe (ContractRef epArg))))
-> (exAddr -> StatementF IndigoM (Var (Maybe (ContractRef epArg))))
-> exAddr
-> IndigoM (Var (Maybe (ContractRef epArg)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy (cp, vd)
-> epRef
-> Expr addr
-> StatementF IndigoM (Var (Maybe (ContractRef epArg)))
forall cp epRef epArg vd addr (freer :: * -> *).
(HasEntrypointArg cp epRef epArg, ToTAddress cp vd addr,
ToT addr ~ ToT Address, KnownValue epArg,
IsoValue (ContractRef epArg)) =>
Proxy (cp, vd)
-> epRef
-> Expr addr
-> StatementF freer (Var (Maybe (ContractRef epArg)))
ContractCalling (forall {t}. Proxy t
forall {k} (t :: k). Proxy t
Proxy @(cp, vd)) epRef
epRef (Expr addr -> StatementF IndigoM (Var (Maybe (ContractRef epArg))))
-> (exAddr -> Expr addr)
-> exAddr
-> StatementF IndigoM (Var (Maybe (ContractRef epArg)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exAddr -> Expr addr
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr
transferTokens
:: ( IsExpr exp p
, IsExpr exm Mutez
, IsExpr exc (ContractRef p)
, NiceParameter p
, HasSideEffects
, HasCallStack
, IsNotInView
)
=> exp -> exm -> exc -> IndigoM ()
transferTokens :: forall exp p exm exc.
(IsExpr exp p, IsExpr exm Mutez, IsExpr exc (ContractRef p),
NiceParameter p, HasSideEffects, HasCallStack, IsNotInView) =>
exp -> exm -> exc -> IndigoM ()
transferTokens exp
ep exm
em exc
ec = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM () -> IndigoM ()
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM () -> IndigoM ())
-> StatementF IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$
Expr p
-> Expr Mutez -> Expr (ContractRef p) -> StatementF IndigoM ()
forall p (freer :: * -> *).
(NiceParameter p, HasSideEffects, IsNotInView) =>
Expr p -> Expr Mutez -> Expr (ContractRef p) -> StatementF freer ()
TransferTokens (exp -> Expr (ExprType exp)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exp
ep) (exm -> Expr (ExprType exm)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exm
em) (exc -> Expr (ExprType exc)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exc
ec)
setDelegate
:: (HasSideEffects, IsExpr ex (Maybe KeyHash), HasCallStack, IsNotInView)
=> ex -> IndigoM ()
setDelegate :: forall ex.
(HasSideEffects, IsExpr ex (Maybe KeyHash), HasCallStack,
IsNotInView) =>
ex -> IndigoM ()
setDelegate = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (ex -> IndigoM ()) -> ex -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM () -> IndigoM ()
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM () -> IndigoM ())
-> (ex -> StatementF IndigoM ()) -> ex -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr (Maybe KeyHash) -> StatementF IndigoM ()
forall (freer :: * -> *).
(HasSideEffects, IsNotInView) =>
Expr (Maybe KeyHash) -> StatementF freer ()
SetDelegate (Expr (Maybe KeyHash) -> StatementF IndigoM ())
-> (ex -> Expr (Maybe KeyHash)) -> ex -> StatementF IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr (Maybe KeyHash)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr
createContract
:: forall st exk exm exs param.
( IsObject st
, IsExpr exk (Maybe KeyHash), IsExpr exm Mutez, IsExpr exs st
, NiceStorageFull st, NiceParameterFull param
, HasSideEffects
, HasCallStack
, IsNotInView
)
=> (HasStorage st => Var param -> IndigoM ())
-> exk
-> exm
-> exs
-> IndigoM (Var Address)
createContract :: forall st exk exm exs param.
(IsObject st, IsExpr exk (Maybe KeyHash), IsExpr exm Mutez,
IsExpr exs st, NiceStorageFull st, NiceParameterFull param,
HasSideEffects, HasCallStack, IsNotInView) =>
(HasStorage st => Var param -> IndigoM ())
-> exk -> exm -> exs -> IndigoM (Var Address)
createContract HasStorage st => Var param -> IndigoM ()
iCtr exk
ek exm
em exs
es = IndigoM (Var Address) -> IndigoM (Var Address)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (Var Address) -> IndigoM (Var Address))
-> IndigoM (Var Address) -> IndigoM (Var Address)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (Var Address) -> IndigoM (Var Address)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (Var Address) -> IndigoM (Var Address))
-> StatementF IndigoM (Var Address) -> IndigoM (Var Address)
forall a b. (a -> b) -> a -> b
$
Contract param st ()
-> Expr (Maybe KeyHash)
-> Expr Mutez
-> Expr st
-> StatementF IndigoM (Var Address)
forall st param vd (freer :: * -> *).
(IsObject st, NiceStorage st, NiceParameterFull param,
HasSideEffects, NiceViewsDescriptor vd, Typeable vd,
IsNotInView) =>
Contract param st vd
-> Expr (Maybe KeyHash)
-> Expr Mutez
-> Expr st
-> StatementF freer (Var Address)
CreateContract (ContractCode param st -> Contract param st ()
forall cp st.
(NiceParameterFull cp, NiceStorageFull st) =>
ContractCode cp st -> Contract cp st ()
mkContract (ContractCode param st -> Contract param st ())
-> ContractCode param st -> Contract param st ()
forall a b. (a -> b) -> a -> b
$ IndigoContract param st -> ContractCode param st
forall param st.
(KnownValue param, IsObject st) =>
IndigoContract param st -> ContractCode param st
compileIndigoContract IndigoContract param st
HasStorage st => Var param -> IndigoM ()
iCtr) (exk -> Expr (ExprType exk)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exk
ek) (exm -> Expr (ExprType exm)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exm
em) (exs -> Expr (ExprType exs)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exs
es)
createLorentzContract
:: ( IsObject st
, IsExpr exk (Maybe KeyHash), IsExpr exm Mutez, IsExpr exs st
, NiceStorage st, NiceParameterFull param, NiceViewsDescriptor vd, Typeable vd
, HasSideEffects
, HasCallStack
, IsNotInView
)
=> L.Contract param st vd
-> exk
-> exm
-> exs
-> IndigoM (Var Address)
createLorentzContract :: forall st exk exm exs param vd.
(IsObject st, IsExpr exk (Maybe KeyHash), IsExpr exm Mutez,
IsExpr exs st, NiceStorage st, NiceParameterFull param,
NiceViewsDescriptor vd, Typeable vd, HasSideEffects, HasCallStack,
IsNotInView) =>
Contract param st vd -> exk -> exm -> exs -> IndigoM (Var Address)
createLorentzContract Contract param st vd
lCtr exk
ek exm
em exs
es = IndigoM (Var Address) -> IndigoM (Var Address)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (Var Address) -> IndigoM (Var Address))
-> IndigoM (Var Address) -> IndigoM (Var Address)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (Var Address) -> IndigoM (Var Address)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (Var Address) -> IndigoM (Var Address))
-> StatementF IndigoM (Var Address) -> IndigoM (Var Address)
forall a b. (a -> b) -> a -> b
$
Contract param st vd
-> Expr (Maybe KeyHash)
-> Expr Mutez
-> Expr st
-> StatementF IndigoM (Var Address)
forall st param vd (freer :: * -> *).
(IsObject st, NiceStorage st, NiceParameterFull param,
HasSideEffects, NiceViewsDescriptor vd, Typeable vd,
IsNotInView) =>
Contract param st vd
-> Expr (Maybe KeyHash)
-> Expr Mutez
-> Expr st
-> StatementF freer (Var Address)
CreateContract Contract param st vd
lCtr (exk -> Expr (ExprType exk)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exk
ek) (exm -> Expr (ExprType exm)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exm
em) (exs -> Expr (ExprType exs)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exs
es)
emit
:: (HasSideEffects, NicePackedValue a, HasAnnotation a, HasCallStack)
=> FieldAnn -> Expr a -> IndigoM ()
emit :: forall a.
(HasSideEffects, NicePackedValue a, HasAnnotation a,
HasCallStack) =>
FieldAnn -> Expr a -> IndigoM ()
emit FieldAnn
tag Expr a
ex = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM () -> IndigoM ()
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM () -> IndigoM ())
-> StatementF IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ FieldAnn -> Expr a -> StatementF IndigoM ()
forall a1 (freer :: * -> *).
(HasSideEffects, NicePackedValue a1, HasAnnotation a1) =>
FieldAnn -> Expr a1 -> StatementF freer ()
Emit FieldAnn
tag Expr a
ex
failWith
:: forall ret a ex.
(NiceConstant a, IsExpr ex a, ReturnableValue ret, HasCallStack)
=> ex -> IndigoM (RetVars ret)
failWith :: forall ret a ex.
(NiceConstant a, IsExpr ex a, ReturnableValue ret, HasCallStack) =>
ex -> IndigoM (RetVars ret)
failWith = IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (ex -> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> ex
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (ex
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> ex
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy ret
-> (forall (inp :: [*]). Expr a -> SomeIndigoState inp)
-> Expr a
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall ret a1 (freer :: * -> *).
ReturnableValue ret =>
Proxy ret
-> (forall (inp :: [*]). Expr a1 -> SomeIndigoState inp)
-> Expr a1
-> StatementF freer (RetVars' (ClassifyReturnValue ret) ret)
FailOver (forall {t}. Proxy t
forall {k} (t :: k). Proxy t
Proxy @ret) (IndigoState inp Any -> SomeIndigoState inp
forall (inp :: [*]) (out :: [*]).
IndigoState inp out -> SomeIndigoState inp
toSIS (IndigoState inp Any -> SomeIndigoState inp)
-> (Expr a -> IndigoState inp Any) -> Expr a -> SomeIndigoState inp
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr a -> IndigoState inp Any
forall a (s :: [*]) (t :: [*]).
NiceConstant a =>
Expr a -> IndigoState s t
B.failWith) (Expr a
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (ex -> Expr a)
-> ex
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr a
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr
failUsing_
:: forall ret x. (IsError x, Buildable x, ReturnableValue ret, HasCallStack)
=> x -> IndigoM (RetVars ret)
failUsing_ :: forall ret x.
(IsError x, Buildable x, ReturnableValue ret, HasCallStack) =>
x -> IndigoM (RetVars ret)
failUsing_ x
x = IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a b. (a -> b) -> a -> b
$ Proxy ret
-> (forall (inp :: [*]). SomeIndigoState inp)
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall ret (freer :: * -> *).
ReturnableValue ret =>
Proxy ret
-> (forall (inp :: [*]). SomeIndigoState inp)
-> StatementF freer (RetVars' (ClassifyReturnValue ret) ret)
Fail (forall {t}. Proxy t
forall {k} (t :: k). Proxy t
Proxy @ret) (IndigoState inp Any -> SomeIndigoState inp
forall (inp :: [*]) (out :: [*]).
IndigoState inp out -> SomeIndigoState inp
toSIS (IndigoState inp Any -> SomeIndigoState inp)
-> IndigoState inp Any -> SomeIndigoState inp
forall a b. (a -> b) -> a -> b
$ x -> IndigoState inp Any
forall x (s :: [*]) (t :: [*]).
(IsError x, Buildable x) =>
x -> IndigoState s t
B.failUsing_ x
x)
failCustom
:: forall ret tag err ex.
( ReturnableValue ret
, MustHaveErrorArg tag (MText, err)
, CustomErrorHasDoc tag
, NiceConstant err
, ex :~> err
, HasCallStack
)
=> Label tag -> ex -> IndigoM (RetVars ret)
failCustom :: forall ret (tag :: Symbol) err ex.
(ReturnableValue ret, MustHaveErrorArg tag (MText, err),
CustomErrorHasDoc tag, NiceConstant err, ex :~> err,
HasCallStack) =>
Label tag -> ex -> IndigoM (RetVars ret)
failCustom Label tag
l = IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (ex -> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> ex
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (ex
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> ex
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy ret
-> (forall (inp :: [*]). Expr err -> SomeIndigoState inp)
-> Expr err
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall ret a1 (freer :: * -> *).
ReturnableValue ret =>
Proxy ret
-> (forall (inp :: [*]). Expr a1 -> SomeIndigoState inp)
-> Expr a1
-> StatementF freer (RetVars' (ClassifyReturnValue ret) ret)
FailOver (forall {t}. Proxy t
forall {k} (t :: k). Proxy t
Proxy @ret) (IndigoState inp Any -> SomeIndigoState inp
forall (inp :: [*]) (out :: [*]).
IndigoState inp out -> SomeIndigoState inp
toSIS (IndigoState inp Any -> SomeIndigoState inp)
-> (Expr err -> IndigoState inp Any)
-> Expr err
-> SomeIndigoState inp
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Label tag -> Expr err -> IndigoState inp Any
forall (tag :: Symbol) err (s :: [*]) (t :: [*]).
(MustHaveErrorArg tag (MText, err), CustomErrorHasDoc tag,
NiceConstant err) =>
Label tag -> Expr err -> IndigoState s t
B.failCustom Label tag
l) (Expr err
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> (ex -> Expr err)
-> ex
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr err
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr
failCustom_
:: forall ret tag.
( ReturnableValue ret
, MustHaveErrorArg tag (MText, ())
, CustomErrorHasDoc tag
, HasCallStack
)
=> Label tag -> IndigoM (RetVars ret)
failCustom_ :: forall ret (tag :: Symbol).
(ReturnableValue ret, MustHaveErrorArg tag (MText, ()),
CustomErrorHasDoc tag, HasCallStack) =>
Label tag -> IndigoM (RetVars ret)
failCustom_ Label tag
tag = IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a b. (a -> b) -> a -> b
$ Proxy ret
-> (forall (inp :: [*]). SomeIndigoState inp)
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall ret (freer :: * -> *).
ReturnableValue ret =>
Proxy ret
-> (forall (inp :: [*]). SomeIndigoState inp)
-> StatementF freer (RetVars' (ClassifyReturnValue ret) ret)
Fail (forall {t}. Proxy t
forall {k} (t :: k). Proxy t
Proxy @ret) (IndigoState inp Any -> SomeIndigoState inp
forall (inp :: [*]) (out :: [*]).
IndigoState inp out -> SomeIndigoState inp
toSIS (IndigoState inp Any -> SomeIndigoState inp)
-> IndigoState inp Any -> SomeIndigoState inp
forall a b. (a -> b) -> a -> b
$ Label tag -> IndigoState inp Any
forall (tag :: Symbol) (s :: [*]) (t :: [*]).
(MustHaveErrorArg tag (MText, ()), CustomErrorHasDoc tag) =>
Label tag -> IndigoState s t
B.failCustom_ Label tag
tag)
failCustomNoArg
:: forall ret tag.
( ReturnableValue ret
, MustHaveErrorArg tag MText
, CustomErrorHasDoc tag
, HasCallStack
)
=> Label tag -> IndigoM (RetVars ret)
failCustomNoArg :: forall ret (tag :: Symbol).
(ReturnableValue ret, MustHaveErrorArg tag MText,
CustomErrorHasDoc tag, HasCallStack) =>
Label tag -> IndigoM (RetVars ret)
failCustomNoArg Label tag
tag = IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a b. (a -> b) -> a -> b
$ Proxy ret
-> (forall (inp :: [*]). SomeIndigoState inp)
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall ret (freer :: * -> *).
ReturnableValue ret =>
Proxy ret
-> (forall (inp :: [*]). SomeIndigoState inp)
-> StatementF freer (RetVars' (ClassifyReturnValue ret) ret)
Fail (forall {t}. Proxy t
forall {k} (t :: k). Proxy t
Proxy @ret) (IndigoState inp Any -> SomeIndigoState inp
forall (inp :: [*]) (out :: [*]).
IndigoState inp out -> SomeIndigoState inp
toSIS (IndigoState inp Any -> SomeIndigoState inp)
-> IndigoState inp Any -> SomeIndigoState inp
forall a b. (a -> b) -> a -> b
$ Label tag -> IndigoState inp Any
forall (tag :: Symbol) (s :: [*]) (t :: [*]).
(MustHaveErrorArg tag MText, CustomErrorHasDoc tag) =>
Label tag -> IndigoState s t
B.failCustomNoArg Label tag
tag)
failUnexpected_
:: forall ret. (ReturnableValue ret, HasCallStack)
=> MText -> IndigoM (RetVars ret)
failUnexpected_ :: forall ret.
(ReturnableValue ret, HasCallStack) =>
MText -> IndigoM (RetVars ret)
failUnexpected_ MText
tx = IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a b. (a -> b) -> a -> b
$ StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a. StatementF IndigoM a -> IndigoM a
oneIndigoM (StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret))
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
-> IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall a b. (a -> b) -> a -> b
$ Proxy ret
-> (forall (inp :: [*]). SomeIndigoState inp)
-> StatementF IndigoM (RetVars' (ClassifyReturnValue ret) ret)
forall ret (freer :: * -> *).
ReturnableValue ret =>
Proxy ret
-> (forall (inp :: [*]). SomeIndigoState inp)
-> StatementF freer (RetVars' (ClassifyReturnValue ret) ret)
Fail (forall {t}. Proxy t
forall {k} (t :: k). Proxy t
Proxy @ret) (IndigoState inp Any -> SomeIndigoState inp
forall (inp :: [*]) (out :: [*]).
IndigoState inp out -> SomeIndigoState inp
toSIS (IndigoState inp Any -> SomeIndigoState inp)
-> IndigoState inp Any -> SomeIndigoState inp
forall a b. (a -> b) -> a -> b
$ MText -> IndigoState inp Any
forall (s :: [*]) (t :: [*]). MText -> IndigoState s t
B.failUnexpected_ MText
tx)
assert
:: forall x ex.
( IsError x
, Buildable x
, IsExpr ex Bool
, HasCallStack
)
=> x -> ex -> IndigoM ()
assert :: forall x ex.
(IsError x, Buildable x, IsExpr ex Bool, HasCallStack) =>
x -> ex -> IndigoM ()
assert x
err ex
ex = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ ex -> IndigoM () -> IndigoM () -> IndigoFunction ()
forall a b ex.
(IfConstraint a b, ex :~> Bool, HasCallStack) =>
ex -> IndigoM a -> IndigoM b -> IndigoM (RetVars a)
if_ ex
ex (() -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()) (forall ret x.
(IsError x, Buildable x, ReturnableValue ret, HasCallStack) =>
x -> IndigoM (RetVars ret)
failUsing_ @() x
err)
assertCustom
:: forall tag err errEx ex.
( MustHaveErrorArg tag (MText, err)
, CustomErrorHasDoc tag
, NiceConstant err
, IsExpr errEx err
, IsExpr ex Bool
, HasCallStack
)
=> Label tag -> errEx -> ex -> IndigoM ()
assertCustom :: forall (tag :: Symbol) err errEx ex.
(MustHaveErrorArg tag (MText, err), CustomErrorHasDoc tag,
NiceConstant err, IsExpr errEx err, IsExpr ex Bool,
HasCallStack) =>
Label tag -> errEx -> ex -> IndigoM ()
assertCustom Label tag
tag errEx
errEx ex
ex = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ ex -> IndigoM () -> IndigoM () -> IndigoFunction ()
forall a b ex.
(IfConstraint a b, ex :~> Bool, HasCallStack) =>
ex -> IndigoM a -> IndigoM b -> IndigoM (RetVars a)
if_ ex
ex (() -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()) (forall ret (tag :: Symbol) err ex.
(ReturnableValue ret, MustHaveErrorArg tag (MText, err),
CustomErrorHasDoc tag, NiceConstant err, ex :~> err,
HasCallStack) =>
Label tag -> ex -> IndigoM (RetVars ret)
failCustom @() Label tag
tag errEx
errEx)
assertCustom_
:: forall tag ex.
( MustHaveErrorArg tag (MText, ())
, CustomErrorHasDoc tag
, IsExpr ex Bool
, HasCallStack
)
=> Label tag -> ex -> IndigoM ()
assertCustom_ :: forall (tag :: Symbol) ex.
(MustHaveErrorArg tag (MText, ()), CustomErrorHasDoc tag,
IsExpr ex Bool, HasCallStack) =>
Label tag -> ex -> IndigoM ()
assertCustom_ Label tag
tag ex
ex = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ ex -> IndigoM () -> IndigoM () -> IndigoFunction ()
forall a b ex.
(IfConstraint a b, ex :~> Bool, HasCallStack) =>
ex -> IndigoM a -> IndigoM b -> IndigoM (RetVars a)
if_ ex
ex (() -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()) (forall ret (tag :: Symbol).
(ReturnableValue ret, MustHaveErrorArg tag (MText, ()),
CustomErrorHasDoc tag, HasCallStack) =>
Label tag -> IndigoM (RetVars ret)
failCustom_ @() Label tag
tag)
assertCustomNoArg
:: forall tag ex.
( MustHaveErrorArg tag MText
, CustomErrorHasDoc tag
, IsExpr ex Bool
, HasCallStack
)
=> Label tag -> ex -> IndigoM ()
assertCustomNoArg :: forall (tag :: Symbol) ex.
(MustHaveErrorArg tag MText, CustomErrorHasDoc tag, IsExpr ex Bool,
HasCallStack) =>
Label tag -> ex -> IndigoM ()
assertCustomNoArg Label tag
tag ex
ex = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ ex -> IndigoM () -> IndigoM () -> IndigoFunction ()
forall a b ex.
(IfConstraint a b, ex :~> Bool, HasCallStack) =>
ex -> IndigoM a -> IndigoM b -> IndigoM (RetVars a)
if_ ex
ex (() -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()) (forall ret (tag :: Symbol).
(ReturnableValue ret, MustHaveErrorArg tag MText,
CustomErrorHasDoc tag, HasCallStack) =>
Label tag -> IndigoM (RetVars ret)
failCustomNoArg @() Label tag
tag)
assertSome
:: forall x err ex.
( IsError err
, Buildable err
, KnownValue x
, ex :~> Maybe x
, HasCallStack
)
=> err -> ex -> IndigoM ()
assertSome :: forall x err ex.
(IsError err, Buildable err, KnownValue x, ex :~> Maybe x,
HasCallStack) =>
err -> ex -> IndigoM ()
assertSome err
err ex
ex = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ ex -> (Var x -> IndigoM ()) -> IndigoM () -> IndigoFunction ()
forall x a b ex.
(KnownValue x, ex :~> Maybe x, IfConstraint a b, HasCallStack) =>
ex -> (Var x -> IndigoM a) -> IndigoM b -> IndigoM (RetVars a)
ifSome ex
ex (\Var x
_ -> forall ret x.
(IsError x, Buildable x, ReturnableValue ret, HasCallStack) =>
x -> IndigoM (RetVars ret)
failUsing_ @() err
err) (() -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
assertNone
:: forall x err ex.
( IsError err
, Buildable err
, KnownValue x
, ex :~> Maybe x
, HasCallStack
)
=> err -> ex -> IndigoM ()
assertNone :: forall x err ex.
(IsError err, Buildable err, KnownValue x, ex :~> Maybe x,
HasCallStack) =>
err -> ex -> IndigoM ()
assertNone err
err ex
ex = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ ex -> (Var x -> IndigoM ()) -> IndigoM () -> IndigoFunction ()
forall x a b ex.
(KnownValue x, ex :~> Maybe x, IfConstraint a b, HasCallStack) =>
ex -> (Var x -> IndigoM a) -> IndigoM b -> IndigoM (RetVars a)
ifSome ex
ex (\Var x
_ -> () -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()) (forall ret x.
(IsError x, Buildable x, ReturnableValue ret, HasCallStack) =>
x -> IndigoM (RetVars ret)
failUsing_ @() err
err)
assertRight
:: forall x y err ex.
( IsError err
, Buildable err
, KnownValue x
, KnownValue y
, ex :~> Either y x
, HasCallStack
)
=> err -> ex -> IndigoM ()
assertRight :: forall x y err ex.
(IsError err, Buildable err, KnownValue x, KnownValue y,
ex :~> Either y x, HasCallStack) =>
err -> ex -> IndigoM ()
assertRight err
err ex
ex = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ ex
-> (Var x -> IndigoM ())
-> (Var y -> IndigoM ())
-> IndigoFunction ()
forall x y a b ex.
(KnownValue x, KnownValue y, ex :~> Either y x, IfConstraint a b,
HasCallStack) =>
ex
-> (Var x -> IndigoM a)
-> (Var y -> IndigoM b)
-> IndigoM (RetVars a)
ifRight ex
ex (\Var x
_ -> forall ret x.
(IsError x, Buildable x, ReturnableValue ret, HasCallStack) =>
x -> IndigoM (RetVars ret)
failUsing_ @() err
err) (\Var y
_ -> () -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
assertLeft
:: forall x y err ex.
( IsError err
, Buildable err
, KnownValue x
, KnownValue y
, ex :~> Either y x
, HasCallStack
)
=> err -> ex -> IndigoM ()
assertLeft :: forall x y err ex.
(IsError err, Buildable err, KnownValue x, KnownValue y,
ex :~> Either y x, HasCallStack) =>
err -> ex -> IndigoM ()
assertLeft err
err ex
ex = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ ex
-> (Var x -> IndigoM ())
-> (Var y -> IndigoM ())
-> IndigoFunction ()
forall x y a b ex.
(KnownValue x, KnownValue y, ex :~> Either y x, IfConstraint a b,
HasCallStack) =>
ex
-> (Var x -> IndigoM a)
-> (Var y -> IndigoM b)
-> IndigoM (RetVars a)
ifRight ex
ex (\Var x
_ -> () -> IndigoM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()) (\Var y
_ -> forall ret x.
(IsError x, Buildable x, ReturnableValue ret, HasCallStack) =>
x -> IndigoM (RetVars ret)
failUsing_ @() err
err)
justComment :: HasCallStack => Text -> IndigoM ()
= IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ())
-> (Text -> IndigoM ()) -> Text -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HasCallStack => CommentType -> IndigoM ()
CommentType -> IndigoM ()
comment (CommentType -> IndigoM ())
-> (Text -> CommentType) -> Text -> IndigoM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> CommentType
MT.JustComment
comment :: HasCallStack => MT.CommentType -> IndigoM ()
CommentType
t = IndigoM () -> IndigoM ()
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM () -> IndigoM ()) -> IndigoM () -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ (forall (inp :: [*]). SomeIndigoState inp) -> IndigoM ()
liftIndigoState ((forall (inp :: [*]). SomeIndigoState inp) -> IndigoM ())
-> (forall (inp :: [*]). SomeIndigoState inp) -> IndigoM ()
forall a b. (a -> b) -> a -> b
$ IndigoState inp inp -> SomeIndigoState inp
forall (inp :: [*]) (out :: [*]).
IndigoState inp out -> SomeIndigoState inp
toSIS (CommentType -> IndigoState inp inp
forall (i :: [*]). CommentType -> IndigoState i i
B.comment CommentType
t)
commentAroundFun :: HasCallStack => Text -> IndigoM a -> IndigoM a
Text
fName IndigoM a
body = IndigoM a -> IndigoM a
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM a -> IndigoM a) -> IndigoM a -> IndigoM a
forall a b. (a -> b) -> a -> b
$
HasCallStack => CommentType -> IndigoM ()
CommentType -> IndigoM ()
comment (Text -> CommentType
MT.FunctionStarts Text
fName) IndigoM () -> IndigoM a -> IndigoM a
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
IndigoM a
body IndigoM a -> (a -> IndigoM a) -> IndigoM a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
\a
res -> a
res a -> IndigoM () -> IndigoM a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ HasCallStack => CommentType -> IndigoM ()
CommentType -> IndigoM ()
comment (Text -> CommentType
MT.FunctionEnds Text
fName)
commentAroundStmt :: HasCallStack => Text -> IndigoM a -> IndigoM a
Text
sName IndigoM a
body = IndigoM a -> IndigoM a
forall a. HasCallStack => IndigoM a -> IndigoM a
calledFrom (IndigoM a -> IndigoM a) -> IndigoM a -> IndigoM a
forall a b. (a -> b) -> a -> b
$
HasCallStack => CommentType -> IndigoM ()
CommentType -> IndigoM ()
comment (Text -> CommentType
MT.StatementStarts Text
sName) IndigoM () -> IndigoM a -> IndigoM a
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
IndigoM a
body IndigoM a -> (a -> IndigoM a) -> IndigoM a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
\a
res -> a
res a -> IndigoM () -> IndigoM a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ HasCallStack => CommentType -> IndigoM ()
CommentType -> IndigoM ()
comment (Text -> CommentType
MT.StatementEnds Text
sName)