{-# LANGUAGE AllowAmbiguousTypes,
MagicHash,
TypeApplications,
TypeFamilies #-}
module Parsley.Internal.Backend.Machine.Types.Statics (
StaHandler#, StaHandler(..), StaHandlerCase, WStaHandler#, WDynHandler,
mkStaHandler, mkStaHandlerNoOffset, mkStaHandlerDyn, mkStaHandlerFull,
staHandler#, staHandlerEval,
staHandlerCharacteristicSta, staHandlerCharacteristicDyn,
StaCont#, StaCont(..),
mkStaCont, mkStaContDyn,
staCont#,
QSubroutine(..), StaSubroutine, StaSubroutine#, StaFunc,
qSubroutine, mkStaSubroutine, mkStaSubroutineMeta,
staSubroutine#, meta,
) where
import Control.Monad.ST (ST)
import Data.STRef (STRef)
import Data.Kind (Type)
import Data.Maybe (fromMaybe)
import Parsley.Internal.Backend.Machine.InputRep (Rep)
import Parsley.Internal.Backend.Machine.LetBindings (Regs(..), Metadata, newMeta, InputCharacteristic(..))
import Parsley.Internal.Backend.Machine.Types.Dynamics (DynCont, DynHandler, DynFunc)
import Parsley.Internal.Backend.Machine.Types.Offset (Offset(offset), same)
import Parsley.Internal.Common.Utils (Code)
type StaHandler# s o a = Code (Rep o) -> Code (ST s (Maybe a))
mkStaHandler# :: forall o s a. DynHandler s o a -> StaHandler# s o a
mkStaHandler# :: DynHandler s o a -> StaHandler# s o a
mkStaHandler# DynHandler s o a
dh Code (Rep o)
qo# = [||$$dh $$(qo#)||]
data StaHandler s o a =
StaHandler
(Maybe (Offset o))
(StaHandlerCase WStaHandler# s o a)
(Maybe (StaHandlerCase WDynHandler s o a))
staHandler# :: StaHandler s o a -> StaHandler# s o a
staHandler# :: StaHandler s o a -> StaHandler# s o a
staHandler# (StaHandler Maybe (Offset o)
_ StaHandlerCase WStaHandler# s o a
sh Maybe (StaHandlerCase WDynHandler s o a)
_) = WStaHandler# s o a -> StaHandler# s o a
forall s o a. WStaHandler# s o a -> StaHandler# s o a
unWrapSta (StaHandlerCase WStaHandler# s o a -> WStaHandler# s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a -> h s o a
unknown StaHandlerCase WStaHandler# s o a
sh)
_mkStaHandler :: Maybe (Offset o) -> StaHandler# s o a -> StaHandler s o a
_mkStaHandler :: Maybe (Offset o) -> StaHandler# s o a -> StaHandler s o a
_mkStaHandler Maybe (Offset o)
o StaHandler# s o a
sh = Maybe (Offset o)
-> StaHandlerCase WStaHandler# s o a
-> Maybe (StaHandlerCase WDynHandler s o a)
-> StaHandler s o a
forall s o a.
Maybe (Offset o)
-> StaHandlerCase WStaHandler# s o a
-> Maybe (StaHandlerCase WDynHandler s o a)
-> StaHandler s o a
StaHandler Maybe (Offset o)
o (StaHandler# s o a -> StaHandlerCase WStaHandler# s o a
forall s o a.
StaHandler# s o a -> StaHandlerCase WStaHandler# s o a
mkUnknownSta StaHandler# s o a
sh) Maybe (StaHandlerCase WDynHandler s o a)
forall a. Maybe a
Nothing
mkStaHandler :: Offset o -> StaHandler# s o a -> StaHandler s o a
mkStaHandler :: Offset o -> StaHandler# s o a -> StaHandler s o a
mkStaHandler = Maybe (Offset o) -> StaHandler# s o a -> StaHandler s o a
forall o s a.
Maybe (Offset o) -> StaHandler# s o a -> StaHandler s o a
_mkStaHandler (Maybe (Offset o) -> StaHandler# s o a -> StaHandler s o a)
-> (Offset o -> Maybe (Offset o))
-> Offset o
-> StaHandler# s o a
-> StaHandler s o a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Offset o -> Maybe (Offset o)
forall a. a -> Maybe a
Just
mkStaHandlerNoOffset :: StaHandler# s o a -> StaHandler s o a
mkStaHandlerNoOffset :: StaHandler# s o a -> StaHandler s o a
mkStaHandlerNoOffset = Maybe (Offset o) -> StaHandler# s o a -> StaHandler s o a
forall o s a.
Maybe (Offset o) -> StaHandler# s o a -> StaHandler s o a
_mkStaHandler Maybe (Offset o)
forall a. Maybe a
Nothing
mkStaHandlerDyn :: forall s o a. Maybe (Offset o) -> DynHandler s o a -> StaHandler s o a
mkStaHandlerDyn :: Maybe (Offset o) -> DynHandler s o a -> StaHandler s o a
mkStaHandlerDyn Maybe (Offset o)
c DynHandler s o a
dh = Maybe (Offset o)
-> StaHandlerCase WStaHandler# s o a
-> Maybe (StaHandlerCase WDynHandler s o a)
-> StaHandler s o a
forall s o a.
Maybe (Offset o)
-> StaHandlerCase WStaHandler# s o a
-> Maybe (StaHandlerCase WDynHandler s o a)
-> StaHandler s o a
StaHandler Maybe (Offset o)
c (StaHandler# s o a -> StaHandlerCase WStaHandler# s o a
forall s o a.
StaHandler# s o a -> StaHandlerCase WStaHandler# s o a
mkUnknownSta (DynHandler s o a -> StaHandler# s o a
forall o s a. DynHandler s o a -> StaHandler# s o a
mkStaHandler# @o DynHandler s o a
dh)) (StaHandlerCase WDynHandler s o a
-> Maybe (StaHandlerCase WDynHandler s o a)
forall a. a -> Maybe a
Just (DynHandler s o a -> StaHandlerCase WDynHandler s o a
forall s o a. DynHandler s o a -> StaHandlerCase WDynHandler s o a
mkUnknownDyn DynHandler s o a
dh))
mkStaHandlerFull :: forall s o a. Offset o
-> DynHandler s o a
-> Code (ST s (Maybe a))
-> DynHandler s o a
-> StaHandler s o a
mkStaHandlerFull :: Offset o
-> DynHandler s o a
-> Code (ST s (Maybe a))
-> DynHandler s o a
-> StaHandler s o a
mkStaHandlerFull Offset o
c DynHandler s o a
handler Code (ST s (Maybe a))
yes DynHandler s o a
no = Maybe (Offset o)
-> StaHandlerCase WStaHandler# s o a
-> Maybe (StaHandlerCase WDynHandler s o a)
-> StaHandler s o a
forall s o a.
Maybe (Offset o)
-> StaHandlerCase WStaHandler# s o a
-> Maybe (StaHandlerCase WDynHandler s o a)
-> StaHandler s o a
StaHandler (Offset o -> Maybe (Offset o)
forall a. a -> Maybe a
Just Offset o
c)
(StaHandler# s o a
-> Code (ST s (Maybe a))
-> StaHandler# s o a
-> StaHandlerCase WStaHandler# s o a
forall s o a.
StaHandler# s o a
-> Code (ST s (Maybe a))
-> StaHandler# s o a
-> StaHandlerCase WStaHandler# s o a
mkFullSta (DynHandler s o a -> StaHandler# s o a
forall o s a. DynHandler s o a -> StaHandler# s o a
mkStaHandler# @o DynHandler s o a
handler)
Code (ST s (Maybe a))
yes
(DynHandler s o a -> StaHandler# s o a
forall o s a. DynHandler s o a -> StaHandler# s o a
mkStaHandler# @o DynHandler s o a
no))
(StaHandlerCase WDynHandler s o a
-> Maybe (StaHandlerCase WDynHandler s o a)
forall a. a -> Maybe a
Just (DynHandler s o a
-> Code (ST s (Maybe a))
-> DynHandler s o a
-> StaHandlerCase WDynHandler s o a
forall s o a.
DynHandler s o a
-> Code (ST s (Maybe a))
-> DynHandler s o a
-> StaHandlerCase WDynHandler s o a
mkFullDyn DynHandler s o a
handler Code (ST s (Maybe a))
yes DynHandler s o a
no))
staHandlerEval :: StaHandler s o a -> Offset o -> Code (ST s (Maybe a))
staHandlerEval :: StaHandler s o a -> Offset o -> Code (ST s (Maybe a))
staHandlerEval (StaHandler (Just Offset o
c) StaHandlerCase WStaHandler# s o a
sh Maybe (StaHandlerCase WDynHandler s o a)
_) Offset o
o
| Just Bool
True <- Offset o -> Offset o -> Maybe Bool
forall o. Offset o -> Offset o -> Maybe Bool
same Offset o
c Offset o
o = (Code (Rep o) -> Code (ST s (Maybe a)))
-> (Code (ST s (Maybe a)) -> Code (Rep o) -> Code (ST s (Maybe a)))
-> Maybe (Code (ST s (Maybe a)))
-> Code (Rep o)
-> Code (ST s (Maybe a))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (WStaHandler# s o a -> Code (Rep o) -> Code (ST s (Maybe a))
forall s o a. WStaHandler# s o a -> StaHandler# s o a
unWrapSta (StaHandlerCase WStaHandler# s o a -> WStaHandler# s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a -> h s o a
unknown StaHandlerCase WStaHandler# s o a
sh)) Code (ST s (Maybe a)) -> Code (Rep o) -> Code (ST s (Maybe a))
forall a b. a -> b -> a
const (StaHandlerCase WStaHandler# s o a -> Maybe (Code (ST s (Maybe a)))
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a -> Maybe (Code (ST s (Maybe a)))
yesSame StaHandlerCase WStaHandler# s o a
sh) (Offset o -> Code (Rep o)
forall o. Offset o -> Code (Rep o)
offset Offset o
o)
| Just Bool
False <- Offset o -> Offset o -> Maybe Bool
forall o. Offset o -> Offset o -> Maybe Bool
same Offset o
c Offset o
o = WStaHandler# s o a -> Code (Rep o) -> Code (ST s (Maybe a))
forall s o a. WStaHandler# s o a -> StaHandler# s o a
unWrapSta (WStaHandler# s o a
-> Maybe (WStaHandler# s o a) -> WStaHandler# s o a
forall a. a -> Maybe a -> a
fromMaybe (StaHandlerCase WStaHandler# s o a -> WStaHandler# s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a -> h s o a
unknown StaHandlerCase WStaHandler# s o a
sh) (StaHandlerCase WStaHandler# s o a -> Maybe (WStaHandler# s o a)
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a -> Maybe (h s o a)
notSame StaHandlerCase WStaHandler# s o a
sh)) (Offset o -> Code (Rep o)
forall o. Offset o -> Code (Rep o)
offset Offset o
o)
staHandlerEval (StaHandler Maybe (Offset o)
_ StaHandlerCase WStaHandler# s o a
sh Maybe (StaHandlerCase WDynHandler s o a)
_) Offset o
o = WStaHandler# s o a -> Code (Rep o) -> Code (ST s (Maybe a))
forall s o a. WStaHandler# s o a -> StaHandler# s o a
unWrapSta (StaHandlerCase WStaHandler# s o a -> WStaHandler# s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a -> h s o a
unknown StaHandlerCase WStaHandler# s o a
sh) (Offset o -> Code (Rep o)
forall o. Offset o -> Code (Rep o)
offset Offset o
o)
staHandlerCharacteristic :: StaHandlerCase h s o a -> (Code (ST s (Maybe a)) -> h s o a) -> InputCharacteristic -> h s o a
staHandlerCharacteristic :: StaHandlerCase h s o a
-> (Code (ST s (Maybe a)) -> h s o a)
-> InputCharacteristic
-> h s o a
staHandlerCharacteristic StaHandlerCase h s o a
sh Code (ST s (Maybe a)) -> h s o a
conv InputCharacteristic
NeverConsumes = h s o a
-> (Code (ST s (Maybe a)) -> h s o a)
-> Maybe (Code (ST s (Maybe a)))
-> h s o a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (StaHandlerCase h s o a -> h s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a -> h s o a
unknown StaHandlerCase h s o a
sh) Code (ST s (Maybe a)) -> h s o a
conv (StaHandlerCase h s o a -> Maybe (Code (ST s (Maybe a)))
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a -> Maybe (Code (ST s (Maybe a)))
yesSame StaHandlerCase h s o a
sh)
staHandlerCharacteristic StaHandlerCase h s o a
sh Code (ST s (Maybe a)) -> h s o a
_ (AlwaysConsumes Maybe Word
_) = h s o a -> Maybe (h s o a) -> h s o a
forall a. a -> Maybe a -> a
fromMaybe (StaHandlerCase h s o a -> h s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a -> h s o a
unknown StaHandlerCase h s o a
sh) (StaHandlerCase h s o a -> Maybe (h s o a)
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a -> Maybe (h s o a)
notSame StaHandlerCase h s o a
sh)
staHandlerCharacteristic StaHandlerCase h s o a
sh Code (ST s (Maybe a)) -> h s o a
_ InputCharacteristic
MayConsume = StaHandlerCase h s o a -> h s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a -> h s o a
unknown StaHandlerCase h s o a
sh
staHandlerCharacteristicSta :: StaHandlerCase WStaHandler# s o a -> InputCharacteristic -> StaHandler# s o a
staHandlerCharacteristicSta :: StaHandlerCase WStaHandler# s o a
-> InputCharacteristic -> StaHandler# s o a
staHandlerCharacteristicSta StaHandlerCase WStaHandler# s o a
h = WStaHandler# s o a -> StaHandler# s o a
forall s o a. WStaHandler# s o a -> StaHandler# s o a
unWrapSta (WStaHandler# s o a -> StaHandler# s o a)
-> (InputCharacteristic -> WStaHandler# s o a)
-> InputCharacteristic
-> StaHandler# s o a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StaHandlerCase WStaHandler# s o a
-> (Code (ST s (Maybe a)) -> WStaHandler# s o a)
-> InputCharacteristic
-> WStaHandler# s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a
-> (Code (ST s (Maybe a)) -> h s o a)
-> InputCharacteristic
-> h s o a
staHandlerCharacteristic StaHandlerCase WStaHandler# s o a
h (StaHandler# s o a -> WStaHandler# s o a
forall s o a. StaHandler# s o a -> WStaHandler# s o a
WrapSta (StaHandler# s o a -> WStaHandler# s o a)
-> (Code (ST s (Maybe a)) -> StaHandler# s o a)
-> Code (ST s (Maybe a))
-> WStaHandler# s o a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Code (ST s (Maybe a)) -> StaHandler# s o a
forall a b. a -> b -> a
const)
staHandlerCharacteristicDyn :: StaHandlerCase WDynHandler s o a
-> (Code (ST s (Maybe a)) -> DynHandler s o a)
-> InputCharacteristic
-> DynHandler s o a
staHandlerCharacteristicDyn :: StaHandlerCase WDynHandler s o a
-> (Code (ST s (Maybe a)) -> DynHandler s o a)
-> InputCharacteristic
-> DynHandler s o a
staHandlerCharacteristicDyn StaHandlerCase WDynHandler s o a
h Code (ST s (Maybe a)) -> DynHandler s o a
conv = WDynHandler s o a -> DynHandler s o a
forall s o a. WDynHandler s o a -> DynHandler s o a
unWrapDyn (WDynHandler s o a -> DynHandler s o a)
-> (InputCharacteristic -> WDynHandler s o a)
-> InputCharacteristic
-> DynHandler s o a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StaHandlerCase WDynHandler s o a
-> (Code (ST s (Maybe a)) -> WDynHandler s o a)
-> InputCharacteristic
-> WDynHandler s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
StaHandlerCase h s o a
-> (Code (ST s (Maybe a)) -> h s o a)
-> InputCharacteristic
-> h s o a
staHandlerCharacteristic StaHandlerCase WDynHandler s o a
h (DynHandler s o a -> WDynHandler s o a
forall s o a. DynHandler s o a -> WDynHandler s o a
WrapDyn (DynHandler s o a -> WDynHandler s o a)
-> (Code (ST s (Maybe a)) -> DynHandler s o a)
-> Code (ST s (Maybe a))
-> WDynHandler s o a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Code (ST s (Maybe a)) -> DynHandler s o a
conv)
data StaHandlerCase h s (o :: Type) a = StaHandlerCase {
StaHandlerCase h s o a -> h s o a
unknown :: h s o a,
StaHandlerCase h s o a -> Maybe (Code (ST s (Maybe a)))
yesSame :: Maybe (Code (ST s (Maybe a))),
StaHandlerCase h s o a -> Maybe (h s o a)
notSame :: Maybe (h s o a)
}
newtype WStaHandler# s o a = WrapSta { WStaHandler# s o a -> StaHandler# s o a
unWrapSta :: StaHandler# s o a }
newtype WDynHandler s o a = WrapDyn { WDynHandler s o a -> DynHandler s o a
unWrapDyn :: DynHandler s o a }
mkUnknown :: h s o a -> StaHandlerCase h s o a
mkUnknown :: h s o a -> StaHandlerCase h s o a
mkUnknown h s o a
h = h s o a
-> Maybe (Code (ST s (Maybe a)))
-> Maybe (h s o a)
-> StaHandlerCase h s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
h s o a
-> Maybe (Code (ST s (Maybe a)))
-> Maybe (h s o a)
-> StaHandlerCase h s o a
StaHandlerCase h s o a
h Maybe (Code (ST s (Maybe a)))
forall a. Maybe a
Nothing Maybe (h s o a)
forall a. Maybe a
Nothing
mkUnknownSta :: StaHandler# s o a -> StaHandlerCase WStaHandler# s o a
mkUnknownSta :: StaHandler# s o a -> StaHandlerCase WStaHandler# s o a
mkUnknownSta = WStaHandler# s o a -> StaHandlerCase WStaHandler# s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
h s o a -> StaHandlerCase h s o a
mkUnknown (WStaHandler# s o a -> StaHandlerCase WStaHandler# s o a)
-> (StaHandler# s o a -> WStaHandler# s o a)
-> StaHandler# s o a
-> StaHandlerCase WStaHandler# s o a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StaHandler# s o a -> WStaHandler# s o a
forall s o a. StaHandler# s o a -> WStaHandler# s o a
WrapSta
mkUnknownDyn :: DynHandler s o a -> StaHandlerCase WDynHandler s o a
mkUnknownDyn :: DynHandler s o a -> StaHandlerCase WDynHandler s o a
mkUnknownDyn = WDynHandler s o a -> StaHandlerCase WDynHandler s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
h s o a -> StaHandlerCase h s o a
mkUnknown (WDynHandler s o a -> StaHandlerCase WDynHandler s o a)
-> (DynHandler s o a -> WDynHandler s o a)
-> DynHandler s o a
-> StaHandlerCase WDynHandler s o a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DynHandler s o a -> WDynHandler s o a
forall s o a. DynHandler s o a -> WDynHandler s o a
WrapDyn
mkFull :: h s o a -> Code (ST s (Maybe a)) -> h s o a -> StaHandlerCase h s o a
mkFull :: h s o a
-> Code (ST s (Maybe a)) -> h s o a -> StaHandlerCase h s o a
mkFull h s o a
h Code (ST s (Maybe a))
yes h s o a
no = h s o a
-> Maybe (Code (ST s (Maybe a)))
-> Maybe (h s o a)
-> StaHandlerCase h s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
h s o a
-> Maybe (Code (ST s (Maybe a)))
-> Maybe (h s o a)
-> StaHandlerCase h s o a
StaHandlerCase h s o a
h (Code (ST s (Maybe a)) -> Maybe (Code (ST s (Maybe a)))
forall a. a -> Maybe a
Just Code (ST s (Maybe a))
yes) (h s o a -> Maybe (h s o a)
forall a. a -> Maybe a
Just h s o a
no)
mkFullSta :: StaHandler# s o a -> Code (ST s (Maybe a)) -> StaHandler# s o a -> StaHandlerCase WStaHandler# s o a
mkFullSta :: StaHandler# s o a
-> Code (ST s (Maybe a))
-> StaHandler# s o a
-> StaHandlerCase WStaHandler# s o a
mkFullSta StaHandler# s o a
h Code (ST s (Maybe a))
yes StaHandler# s o a
no = WStaHandler# s o a
-> Code (ST s (Maybe a))
-> WStaHandler# s o a
-> StaHandlerCase WStaHandler# s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
h s o a
-> Code (ST s (Maybe a)) -> h s o a -> StaHandlerCase h s o a
mkFull (StaHandler# s o a -> WStaHandler# s o a
forall s o a. StaHandler# s o a -> WStaHandler# s o a
WrapSta StaHandler# s o a
h) Code (ST s (Maybe a))
yes (StaHandler# s o a -> WStaHandler# s o a
forall s o a. StaHandler# s o a -> WStaHandler# s o a
WrapSta StaHandler# s o a
no)
mkFullDyn :: DynHandler s o a -> Code (ST s (Maybe a)) -> DynHandler s o a -> StaHandlerCase WDynHandler s o a
mkFullDyn :: DynHandler s o a
-> Code (ST s (Maybe a))
-> DynHandler s o a
-> StaHandlerCase WDynHandler s o a
mkFullDyn DynHandler s o a
h Code (ST s (Maybe a))
yes DynHandler s o a
no = WDynHandler s o a
-> Code (ST s (Maybe a))
-> WDynHandler s o a
-> StaHandlerCase WDynHandler s o a
forall (h :: Type -> Type -> Type -> Type) s o a.
h s o a
-> Code (ST s (Maybe a)) -> h s o a -> StaHandlerCase h s o a
mkFull (DynHandler s o a -> WDynHandler s o a
forall s o a. DynHandler s o a -> WDynHandler s o a
WrapDyn DynHandler s o a
h) Code (ST s (Maybe a))
yes (DynHandler s o a -> WDynHandler s o a
forall s o a. DynHandler s o a -> WDynHandler s o a
WrapDyn DynHandler s o a
no)
type StaCont# s o a x = Code x -> Code (Rep o) -> Code (ST s (Maybe a))
data StaCont s o a x = StaCont (StaCont# s o a x) (Maybe (DynCont s o a x))
mkStaContDyn :: DynCont s o a x -> StaCont s o a x
mkStaContDyn :: DynCont s o a x -> StaCont s o a x
mkStaContDyn DynCont s o a x
dk = StaCont# s o a x -> Maybe (DynCont s o a x) -> StaCont s o a x
forall s o a x.
StaCont# s o a x -> Maybe (DynCont s o a x) -> StaCont s o a x
StaCont (\Code x
x Code (Rep o)
o# -> [|| $$dk $$x $$(o#) ||]) (DynCont s o a x -> Maybe (DynCont s o a x)
forall a. a -> Maybe a
Just DynCont s o a x
dk)
staCont# :: StaCont s o a x -> StaCont# s o a x
staCont# :: StaCont s o a x -> StaCont# s o a x
staCont# (StaCont StaCont# s o a x
sk Maybe (DynCont s o a x)
_) = StaCont# s o a x
sk
mkStaCont :: StaCont# s o a x -> StaCont s o a x
mkStaCont :: StaCont# s o a x -> StaCont s o a x
mkStaCont StaCont# s o a x
sk = StaCont# s o a x -> Maybe (DynCont s o a x) -> StaCont s o a x
forall s o a x.
StaCont# s o a x -> Maybe (DynCont s o a x) -> StaCont s o a x
StaCont StaCont# s o a x
sk Maybe (DynCont s o a x)
forall a. Maybe a
Nothing
type StaSubroutine# s o a x = DynCont s o a x -> Code (Rep o) -> DynHandler s o a -> Code (ST s (Maybe a))
data StaSubroutine s o a x = StaSubroutine {
StaSubroutine s o a x -> StaSubroutine# s o a x
staSubroutine# :: StaSubroutine# s o a x,
StaSubroutine s o a x -> Metadata
meta :: Metadata
}
mkStaSubroutine :: StaSubroutine# s o a x -> StaSubroutine s o a x
mkStaSubroutine :: StaSubroutine# s o a x -> StaSubroutine s o a x
mkStaSubroutine = Metadata -> StaSubroutine# s o a x -> StaSubroutine s o a x
forall s o a x.
Metadata -> StaSubroutine# s o a x -> StaSubroutine s o a x
mkStaSubroutineMeta Metadata
newMeta
mkStaSubroutineMeta :: Metadata -> StaSubroutine# s o a x -> StaSubroutine s o a x
mkStaSubroutineMeta :: Metadata -> StaSubroutine# s o a x -> StaSubroutine s o a x
mkStaSubroutineMeta = (StaSubroutine# s o a x -> Metadata -> StaSubroutine s o a x)
-> Metadata -> StaSubroutine# s o a x -> StaSubroutine s o a x
forall a b c. (a -> b -> c) -> b -> a -> c
flip StaSubroutine# s o a x -> Metadata -> StaSubroutine s o a x
forall s o a x.
StaSubroutine# s o a x -> Metadata -> StaSubroutine s o a x
StaSubroutine
type family StaFunc (rs :: [Type]) s o a x where
StaFunc '[] s o a x = StaSubroutine s o a x
StaFunc (r : rs) s o a x = Code (STRef s r) -> StaFunc rs s o a x
data QSubroutine s o a x = forall rs. QSubroutine (StaFunc rs s o a x) (Regs rs)
qSubroutine :: forall s o a x rs. DynFunc rs s o a x -> Regs rs -> Metadata -> QSubroutine s o a x
qSubroutine :: DynFunc rs s o a x -> Regs rs -> Metadata -> QSubroutine s o a x
qSubroutine DynFunc rs s o a x
func Regs rs
frees Metadata
meta = StaFunc rs s o a x -> Regs rs -> QSubroutine s o a x
forall s o a x (rs :: [Type]).
StaFunc rs s o a x -> Regs rs -> QSubroutine s o a x
QSubroutine (Regs rs -> DynFunc rs s o a x -> StaFunc rs s o a x
forall (rs :: [Type]).
Regs rs -> DynFunc rs s o a x -> StaFunc rs s o a x
staFunc Regs rs
frees DynFunc rs s o a x
func) Regs rs
frees
where
staFunc :: forall rs. Regs rs -> DynFunc rs s o a x -> StaFunc rs s o a x
staFunc :: Regs rs -> DynFunc rs s o a x -> StaFunc rs s o a x
staFunc Regs rs
NoRegs DynFunc rs s o a x
func = StaSubroutine# s o a x -> Metadata -> StaSubroutine s o a x
forall s o a x.
StaSubroutine# s o a x -> Metadata -> StaSubroutine s o a x
StaSubroutine (\DynCont s o a x
dk Code (Rep o)
o# DynHandler s o a
dh -> [|| $$func $$dk $$(o#) $$dh ||]) Metadata
meta
staFunc (FreeReg ΣVar r
_ Regs rs
witness) DynFunc rs s o a x
func = \Q (TExp (STRef s r))
r -> Regs rs -> DynFunc rs s o a x -> StaFunc rs s o a x
forall (rs :: [Type]).
Regs rs -> DynFunc rs s o a x -> StaFunc rs s o a x
staFunc Regs rs
witness [|| $$func $$r ||]