{-# OPTIONS_GHC -Wno-redundant-constraints #-}
module Indigo.Backend.Scope
( BranchRetKind (..)
, ScopeCodeGen
, ScopeCodeGen' (..)
, ReturnableValue
, ReturnableValue' (..)
, RetOutStack
, RetVars
, RetExprs
, ClassifyReturnValue
, liftClear
, compileScope
, allocateVars
, finalizeStatement
) where
import qualified Data.Kind as Kind
import qualified GHC.TypeLits as Lit
import Util.Type (type (++))
import Indigo.Backend.Prelude
import Indigo.Internal.Expr
import Indigo.Internal.Object
import Indigo.Internal.State
import Indigo.Lorentz
import qualified Lorentz.Instr as L
data BranchRetKind =
Unit
| SingleVal
| Tuple
type family ClassifyReturnValue (ret :: Kind.Type) where
ClassifyReturnValue () = 'Unit
ClassifyReturnValue (_, _) = 'Tuple
ClassifyReturnValue (_, _, _) = 'Tuple
ClassifyReturnValue (_, _, _, _) =
Lit.TypeError ('Lit.Text "Tuple with 4 elements is not supported yet as returning value")
ClassifyReturnValue (_, _, _, _, _) =
Lit.TypeError ('Lit.Text "Tuple with 5 elements is not supported yet as returning value")
ClassifyReturnValue (_, _, _, _, _, _) =
Lit.TypeError ('Lit.Text "Tuple with 6 elements is not supported yet as returning value")
ClassifyReturnValue _ = 'SingleVal
class ReturnableValue' (retKind :: BranchRetKind) (ret :: Kind.Type) where
type family RetOutStack' retKind ret :: [Kind.Type]
type family RetVars' retKind ret :: Kind.Type
type family RetExprs' retKind ret :: Kind.Type
allocateVars'
:: (forall inpt x . KnownValue x => MetaData inpt -> (Var x, MetaData (x & inpt)))
-> MetaData inp
-> (RetVars' retKind ret, MetaData (RetOutStack' retKind ret ++ inp))
class ReturnableValue' retKind ret => ScopeCodeGen' (retKind :: BranchRetKind) (ret :: Kind.Type) where
compileScopeReturn' :: ret -> IndigoState xs (RetOutStack' retKind ret ++ xs) ()
liftClear' :: (xs :-> inp) -> (RetOutStack' retKind ret ++ xs :-> RetOutStack' retKind ret ++ inp)
genGcClear' :: (RetOutStack' retKind ret ++ inp) :-> inp
type RetOutStack ret = RetOutStack' (ClassifyReturnValue ret) ret
type RetVars ret = RetVars' (ClassifyReturnValue ret) ret
type RetExprs ret = RetExprs' (ClassifyReturnValue ret) ret
type ReturnableValue ret = ReturnableValue' (ClassifyReturnValue ret) ret
type ScopeCodeGen ret = ScopeCodeGen' (ClassifyReturnValue ret) ret
allocateVars
:: forall ret inp . ReturnableValue ret
=> (forall inpt x . KnownValue x => MetaData inpt -> (Var x, MetaData (x & inpt)))
-> MetaData inp
-> (RetVars ret, MetaData (RetOutStack ret ++ inp))
allocateVars :: (forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt)))
-> MetaData inp -> (RetVars ret, MetaData (RetOutStack ret ++ inp))
allocateVars = forall (inp :: [*]).
ReturnableValue' (ClassifyReturnValue ret) ret =>
(forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt)))
-> MetaData inp -> (RetVars ret, MetaData (RetOutStack ret ++ inp))
forall (retKind :: BranchRetKind) ret (inp :: [*]).
ReturnableValue' retKind ret =>
(forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt)))
-> MetaData inp
-> (RetVars' retKind ret,
MetaData (RetOutStack' retKind ret ++ inp))
allocateVars' @(ClassifyReturnValue ret) @ret
liftClear
:: forall ret inp xs . ScopeCodeGen ret
=> (xs :-> inp)
-> (RetOutStack ret ++ xs :-> RetOutStack ret ++ inp)
liftClear :: (xs :-> inp)
-> (RetOutStack ret ++ xs) :-> (RetOutStack ret ++ inp)
liftClear = forall (xs :: [*]) (inp :: [*]).
ScopeCodeGen' (ClassifyReturnValue ret) ret =>
(xs :-> inp)
-> (RetOutStack ret ++ xs) :-> (RetOutStack ret ++ inp)
forall (retKind :: BranchRetKind) ret (xs :: [*]) (inp :: [*]).
ScopeCodeGen' retKind ret =>
(xs :-> inp)
-> (RetOutStack' retKind ret ++ xs)
:-> (RetOutStack' retKind ret ++ inp)
liftClear' @(ClassifyReturnValue ret) @ret
compileScope
:: forall ret inp xs . ScopeCodeGen ret
=> GenCode inp xs ret
-> (inp :-> RetOutStack ret ++ inp)
compileScope :: GenCode inp xs ret -> inp :-> (RetOutStack ret ++ inp)
compileScope gc :: GenCode inp xs ret
gc =
GenCode inp xs ret -> inp :-> xs
forall (inp :: [*]) (out :: [*]) a.
GenCode inp out a -> inp :-> out
gcCode GenCode inp xs ret
gc (inp :-> xs)
-> (xs :-> (RetOutStack ret ++ xs))
-> inp :-> (RetOutStack ret ++ xs)
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
#
GenCode xs (RetOutStack ret ++ xs) ()
-> xs :-> (RetOutStack ret ++ xs)
forall (inp :: [*]) (out :: [*]) a.
GenCode inp out a -> inp :-> out
gcCode (IndigoState xs (RetOutStack ret ++ xs) ()
-> MetaData xs -> GenCode xs (RetOutStack ret ++ xs) ()
forall (inp :: [*]) (out :: [*]) a.
IndigoState inp out a -> MetaData inp -> GenCode inp out a
runIndigoState (ret -> IndigoState xs (RetOutStack ret ++ xs) ()
forall (retKind :: BranchRetKind) ret (xs :: [*]).
ScopeCodeGen' retKind ret =>
ret -> IndigoState xs (RetOutStack' retKind ret ++ xs) ()
compileScopeReturn' @(ClassifyReturnValue ret) (GenCode inp xs ret -> ret
forall (inp :: [*]) (out :: [*]) a. GenCode inp out a -> a
gcOut GenCode inp xs ret
gc)) (GenCode inp xs ret -> MetaData xs
forall (inp :: [*]) (out :: [*]) a.
GenCode inp out a -> MetaData out
gcMeta GenCode inp xs ret
gc)) (inp :-> (RetOutStack ret ++ xs))
-> ((RetOutStack ret ++ xs) :-> (RetOutStack ret ++ inp))
-> inp :-> (RetOutStack ret ++ inp)
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
#
(xs :-> inp)
-> (RetOutStack ret ++ xs) :-> (RetOutStack ret ++ inp)
forall (retKind :: BranchRetKind) ret (xs :: [*]) (inp :: [*]).
ScopeCodeGen' retKind ret =>
(xs :-> inp)
-> (RetOutStack' retKind ret ++ xs)
:-> (RetOutStack' retKind ret ++ inp)
liftClear' @(ClassifyReturnValue ret) @ret (GenCode inp xs ret -> xs :-> inp
forall (inp :: [*]) (out :: [*]) a.
GenCode inp out a -> out :-> inp
gcClear GenCode inp xs ret
gc)
finalizeStatement
:: forall ret inp . ScopeCodeGen ret
=> MetaData inp
-> (inp :-> RetOutStack ret ++ inp)
-> GenCode inp (RetOutStack ret ++ inp) (RetVars ret)
finalizeStatement :: MetaData inp
-> (inp :-> (RetOutStack ret ++ inp))
-> GenCode inp (RetOutStack ret ++ inp) (RetVars ret)
finalizeStatement md :: MetaData inp
md code :: inp :-> (RetOutStack ret ++ inp)
code =
let (vars :: RetVars ret
vars, newMd :: MetaData (RetOutStack ret ++ inp)
newMd) = (forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt)))
-> MetaData inp -> (RetVars ret, MetaData (RetOutStack ret ++ inp))
forall (retKind :: BranchRetKind) ret (inp :: [*]).
ReturnableValue' retKind ret =>
(forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt)))
-> MetaData inp
-> (RetVars' retKind ret,
MetaData (RetOutStack' retKind ret ++ inp))
allocateVars' @(ClassifyReturnValue ret) @ret forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt))
forall x (stk :: [*]).
KnownValue x =>
MetaData stk -> (Var x, MetaData (x & stk))
pushRefMd MetaData inp
md in
RetVars ret
-> MetaData (RetOutStack ret ++ inp)
-> (inp :-> (RetOutStack ret ++ inp))
-> ((RetOutStack ret ++ inp) :-> inp)
-> GenCode inp (RetOutStack ret ++ inp) (RetVars ret)
forall (inp :: [*]) (out :: [*]) a.
a
-> MetaData out
-> (inp :-> out)
-> (out :-> inp)
-> GenCode inp out a
GenCode RetVars ret
vars MetaData (RetOutStack ret ++ inp)
newMd inp :-> (RetOutStack ret ++ inp)
code (forall (inp :: [*]).
ScopeCodeGen' (ClassifyReturnValue ret) ret =>
(RetOutStack ret ++ inp) :-> inp
forall (retKind :: BranchRetKind) ret (inp :: [*]).
ScopeCodeGen' retKind ret =>
(RetOutStack' retKind ret ++ inp) :-> inp
genGcClear' @(ClassifyReturnValue ret) @ret)
type KnownValueExpr a = (KnownValue (ExprType a), ToExpr a)
instance ReturnableValue' 'Unit () where
type RetOutStack' 'Unit () = '[]
type RetVars' 'Unit () = ()
type RetExprs' 'Unit () = ()
allocateVars' :: (forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt)))
-> MetaData inp
-> (RetVars' 'Unit (), MetaData (RetOutStack' 'Unit () ++ inp))
allocateVars' _ md :: MetaData inp
md = ((), MetaData inp
MetaData (RetOutStack' 'Unit () ++ inp)
md)
instance ScopeCodeGen' 'Unit () where
compileScopeReturn' :: () -> IndigoState xs (RetOutStack' 'Unit () ++ xs) ()
compileScopeReturn' _ = () -> IndigoState xs xs ()
forall a (inp :: [*]). a -> IndigoState inp inp a
return ()
liftClear' :: (xs :-> inp)
-> (RetOutStack' 'Unit () ++ xs) :-> (RetOutStack' 'Unit () ++ inp)
liftClear' = (xs :-> inp)
-> (RetOutStack' 'Unit () ++ xs) :-> (RetOutStack' 'Unit () ++ inp)
forall a. a -> a
id
genGcClear' :: (RetOutStack' 'Unit () ++ inp) :-> inp
genGcClear' = (RetOutStack' 'Unit () ++ inp) :-> inp
forall (s :: [*]). s :-> s
L.nop
instance KnownValueExpr single => ReturnableValue' 'SingleVal single where
type RetOutStack' 'SingleVal single = '[ExprType single]
type RetVars' 'SingleVal single = Var (ExprType single)
type RetExprs' 'SingleVal single = ExprType single
allocateVars' :: (forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt)))
-> MetaData inp
-> (RetVars' 'SingleVal single,
MetaData (RetOutStack' 'SingleVal single ++ inp))
allocateVars' allocator :: forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt))
allocator = MetaData inp
-> (RetVars' 'SingleVal single,
MetaData (RetOutStack' 'SingleVal single ++ inp))
forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt))
allocator
instance KnownValueExpr single => ScopeCodeGen' 'SingleVal single where
compileScopeReturn' :: single -> IndigoState xs (RetOutStack' 'SingleVal single ++ xs) ()
compileScopeReturn' = single -> IndigoState xs (RetOutStack' 'SingleVal single ++ xs) ()
forall a (inp :: [*]).
ToExpr a =>
a -> IndigoState inp (ExprType a & inp) ()
compileToExpr
liftClear' :: (xs :-> inp)
-> (RetOutStack' 'SingleVal single ++ xs)
:-> (RetOutStack' 'SingleVal single ++ inp)
liftClear' = (xs :-> inp)
-> (RetOutStack' 'SingleVal single ++ xs)
:-> (RetOutStack' 'SingleVal single ++ inp)
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a & s) :-> (a & s')
L.dip
genGcClear' :: (RetOutStack' 'SingleVal single ++ inp) :-> inp
genGcClear' = (RetOutStack' 'SingleVal single ++ inp) :-> inp
forall a (s :: [*]). (a & s) :-> s
L.drop
instance (KnownValueExpr x, KnownValueExpr y) => ReturnableValue' 'Tuple (x, y) where
type RetOutStack' 'Tuple (x, y) = ExprType x ': '[ExprType y]
type RetVars' 'Tuple (x, y) = (Var (ExprType x), Var (ExprType y))
type RetExprs' 'Tuple (x, y) = (ExprType x, ExprType y)
allocateVars' :: (forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt)))
-> MetaData inp
-> (RetVars' 'Tuple (x, y),
MetaData (RetOutStack' 'Tuple (x, y) ++ inp))
allocateVars' allocator :: forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt))
allocator md :: MetaData inp
md =
let (var2 :: Var (ExprType' (Decide y) y)
var2, newMd1 :: MetaData (ExprType' (Decide y) y & inp)
newMd1) = MetaData inp
-> (Var (ExprType' (Decide y) y),
MetaData (ExprType' (Decide y) y & inp))
forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt))
allocator MetaData inp
md in
let (var1 :: Var (ExprType' (Decide x) x)
var1, newMd2 :: MetaData (ExprType' (Decide x) x & (ExprType' (Decide y) y & inp))
newMd2) = MetaData (ExprType' (Decide y) y & inp)
-> (Var (ExprType' (Decide x) x),
MetaData (ExprType' (Decide x) x & (ExprType' (Decide y) y & inp)))
forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt))
allocator MetaData (ExprType' (Decide y) y & inp)
newMd1 in
((Var (ExprType' (Decide x) x)
var1, Var (ExprType' (Decide y) y)
var2), MetaData (ExprType' (Decide x) x & (ExprType' (Decide y) y & inp))
MetaData (RetOutStack' 'Tuple (x, y) ++ inp)
newMd2)
instance (KnownValueExpr x, KnownValueExpr y) => ScopeCodeGen' 'Tuple (x, y) where
compileScopeReturn' :: (x, y) -> IndigoState xs (RetOutStack' 'Tuple (x, y) ++ xs) ()
compileScopeReturn' (e1 :: x
e1, e2 :: y
e2) = y -> IndigoState xs (ExprType' (Decide y) y : xs) ()
forall a (inp :: [*]).
ToExpr a =>
a -> IndigoState inp (ExprType a & inp) ()
compileToExpr y
e2 IndigoState xs (ExprType' (Decide y) y : xs) ()
-> IndigoState
(ExprType' (Decide y) y : xs)
(ExprType' (Decide x) x & (ExprType' (Decide y) y : xs))
()
-> IndigoState
xs (ExprType' (Decide x) x & (ExprType' (Decide y) y : xs)) ()
forall (inp :: [*]) (out :: [*]) a (out1 :: [*]) b.
IndigoState inp out a
-> IndigoState out out1 b -> IndigoState inp out1 b
>> x
-> IndigoState
(ExprType' (Decide y) y : xs)
(ExprType' (Decide x) x & (ExprType' (Decide y) y : xs))
()
forall a (inp :: [*]).
ToExpr a =>
a -> IndigoState inp (ExprType a & inp) ()
compileToExpr x
e1
liftClear' :: (xs :-> inp)
-> (RetOutStack' 'Tuple (x, y) ++ xs)
:-> (RetOutStack' 'Tuple (x, y) ++ inp)
liftClear' = ((ExprType' (Decide y) y & xs) :-> (ExprType' (Decide y) y & inp))
-> (ExprType' (Decide x) x & (ExprType' (Decide y) y & xs))
:-> (ExprType' (Decide x) x & (ExprType' (Decide y) y & inp))
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a & s) :-> (a & s')
L.dip (((ExprType' (Decide y) y & xs) :-> (ExprType' (Decide y) y & inp))
-> (ExprType' (Decide x) x & (ExprType' (Decide y) y & xs))
:-> (ExprType' (Decide x) x & (ExprType' (Decide y) y & inp)))
-> ((xs :-> inp)
-> (ExprType' (Decide y) y & xs)
:-> (ExprType' (Decide y) y & inp))
-> (xs :-> inp)
-> (ExprType' (Decide x) x & (ExprType' (Decide y) y & xs))
:-> (ExprType' (Decide x) x & (ExprType' (Decide y) y & inp))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (xs :-> inp)
-> (ExprType' (Decide y) y & xs) :-> (ExprType' (Decide y) y & inp)
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a & s) :-> (a & s')
L.dip
genGcClear' :: (RetOutStack' 'Tuple (x, y) ++ inp) :-> inp
genGcClear' = (ExprType' (Decide x) x & (ExprType' (Decide y) y & inp))
:-> (ExprType' (Decide y) y & inp)
forall a (s :: [*]). (a & s) :-> s
L.drop ((ExprType' (Decide x) x & (ExprType' (Decide y) y & inp))
:-> (ExprType' (Decide y) y & inp))
-> ((ExprType' (Decide y) y & inp) :-> inp)
-> (ExprType' (Decide x) x & (ExprType' (Decide y) y & inp))
:-> inp
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# (ExprType' (Decide y) y & inp) :-> inp
forall a (s :: [*]). (a & s) :-> s
L.drop
instance (KnownValueExpr x, KnownValueExpr y, KnownValueExpr z) => ReturnableValue' 'Tuple (x, y, z) where
type RetOutStack' 'Tuple (x, y, z) = ExprType x ': ExprType y ': '[ExprType z]
type RetVars' 'Tuple (x, y, z) = (Var (ExprType x), Var (ExprType y), Var (ExprType z))
type RetExprs' 'Tuple (x, y, z) = (ExprType x, ExprType y, ExprType z)
allocateVars' :: (forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt)))
-> MetaData inp
-> (RetVars' 'Tuple (x, y, z),
MetaData (RetOutStack' 'Tuple (x, y, z) ++ inp))
allocateVars' allocator :: forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt))
allocator md :: MetaData inp
md =
let (var3 :: Var (ExprType' (Decide z) z)
var3, newMd1 :: MetaData (ExprType' (Decide z) z & inp)
newMd1) = MetaData inp
-> (Var (ExprType' (Decide z) z),
MetaData (ExprType' (Decide z) z & inp))
forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt))
allocator MetaData inp
md in
let (var2 :: Var (ExprType' (Decide y) y)
var2, newMd2 :: MetaData (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp))
newMd2) = MetaData (ExprType' (Decide z) z & inp)
-> (Var (ExprType' (Decide y) y),
MetaData (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp)))
forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt))
allocator MetaData (ExprType' (Decide z) z & inp)
newMd1 in
let (var1 :: Var (ExprType' (Decide x) x)
var1, newMd3 :: MetaData
(ExprType' (Decide x) x
& (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp)))
newMd3) = MetaData (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp))
-> (Var (ExprType' (Decide x) x),
MetaData
(ExprType' (Decide x) x
& (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp))))
forall (inpt :: [*]) x.
KnownValue x =>
MetaData inpt -> (Var x, MetaData (x & inpt))
allocator MetaData (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp))
newMd2 in
((Var (ExprType' (Decide x) x)
var1, Var (ExprType' (Decide y) y)
var2, Var (ExprType' (Decide z) z)
var3), MetaData
(ExprType' (Decide x) x
& (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp)))
MetaData (RetOutStack' 'Tuple (x, y, z) ++ inp)
newMd3)
instance (KnownValueExpr x, KnownValueExpr y, KnownValueExpr z) => ScopeCodeGen' 'Tuple (x, y, z) where
compileScopeReturn' :: (x, y, z)
-> IndigoState xs (RetOutStack' 'Tuple (x, y, z) ++ xs) ()
compileScopeReturn' (e1 :: x
e1, e2 :: y
e2, e3 :: z
e3) = z -> IndigoState xs (ExprType' (Decide z) z : xs) ()
forall a (inp :: [*]).
ToExpr a =>
a -> IndigoState inp (ExprType a & inp) ()
compileToExpr z
e3 IndigoState xs (ExprType' (Decide z) z : xs) ()
-> IndigoState
(ExprType' (Decide z) z : xs)
(ExprType' (Decide y) y & (ExprType' (Decide z) z : xs))
()
-> IndigoState
xs (ExprType' (Decide y) y & (ExprType' (Decide z) z : xs)) ()
forall (inp :: [*]) (out :: [*]) a (out1 :: [*]) b.
IndigoState inp out a
-> IndigoState out out1 b -> IndigoState inp out1 b
>> y
-> IndigoState
(ExprType' (Decide z) z : xs)
(ExprType' (Decide y) y & (ExprType' (Decide z) z : xs))
()
forall a (inp :: [*]).
ToExpr a =>
a -> IndigoState inp (ExprType a & inp) ()
compileToExpr y
e2 IndigoState
xs (ExprType' (Decide y) y & (ExprType' (Decide z) z : xs)) ()
-> IndigoState
(ExprType' (Decide y) y & (ExprType' (Decide z) z : xs))
(ExprType' (Decide x) x
& (ExprType' (Decide y) y & (ExprType' (Decide z) z : xs)))
()
-> IndigoState
xs
(ExprType' (Decide x) x
& (ExprType' (Decide y) y & (ExprType' (Decide z) z : xs)))
()
forall (inp :: [*]) (out :: [*]) a (out1 :: [*]) b.
IndigoState inp out a
-> IndigoState out out1 b -> IndigoState inp out1 b
>> x
-> IndigoState
(ExprType' (Decide y) y & (ExprType' (Decide z) z : xs))
(ExprType' (Decide x) x
& (ExprType' (Decide y) y & (ExprType' (Decide z) z : xs)))
()
forall a (inp :: [*]).
ToExpr a =>
a -> IndigoState inp (ExprType a & inp) ()
compileToExpr x
e1
liftClear' :: (xs :-> inp)
-> (RetOutStack' 'Tuple (x, y, z) ++ xs)
:-> (RetOutStack' 'Tuple (x, y, z) ++ inp)
liftClear' = forall (inp :: [*]) (out :: [*]) (s :: [*]) (s' :: [*]).
ConstraintDIPNLorentz (ToPeano 3) inp out s s' =>
(s :-> s') -> inp :-> out
forall (n :: Nat) (inp :: [*]) (out :: [*]) (s :: [*]) (s' :: [*]).
ConstraintDIPNLorentz (ToPeano n) inp out s s' =>
(s :-> s') -> inp :-> out
L.dipN @3
genGcClear' :: (RetOutStack' 'Tuple (x, y, z) ++ inp) :-> inp
genGcClear' = (ExprType' (Decide x) x
& (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp)))
:-> (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp))
forall a (s :: [*]). (a & s) :-> s
L.drop ((ExprType' (Decide x) x
& (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp)))
:-> (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp)))
-> ((ExprType' (Decide y) y & (ExprType' (Decide z) z & inp))
:-> (ExprType' (Decide z) z & inp))
-> (ExprType' (Decide x) x
& (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp)))
:-> (ExprType' (Decide z) z & inp)
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp))
:-> (ExprType' (Decide z) z & inp)
forall a (s :: [*]). (a & s) :-> s
L.drop ((ExprType' (Decide x) x
& (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp)))
:-> (ExprType' (Decide z) z & inp))
-> ((ExprType' (Decide z) z & inp) :-> inp)
-> (ExprType' (Decide x) x
& (ExprType' (Decide y) y & (ExprType' (Decide z) z & inp)))
:-> inp
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# (ExprType' (Decide z) z & inp) :-> inp
forall a (s :: [*]). (a & s) :-> s
L.drop
compileToExpr :: ToExpr a => a -> IndigoState inp ((ExprType a) & inp) ()
compileToExpr :: a -> IndigoState inp (ExprType a & inp) ()
compileToExpr = Expr (ExprType a) -> IndigoState inp (ExprType a & inp) ()
forall a (inp :: [*]). Expr a -> IndigoState inp (a & inp) ()
compileExpr (Expr (ExprType a) -> IndigoState inp (ExprType a & inp) ())
-> (a -> Expr (ExprType a))
-> a
-> IndigoState inp (ExprType a & inp) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Expr (ExprType a)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr