Commit 9148384c authored by Katharina Brandl's avatar Katharina Brandl
Browse files

code refactoring into different modules

parent 7ddddeac
......@@ -12,7 +12,6 @@
module ConcreteInterpreter where
import Frame
import GenericInterpreter hiding (eval,evalNumericInst,evalVariableInstr,evalParametricInst,invokeExported)
import qualified GenericInterpreter as Generic
--import Stack
......@@ -22,11 +21,14 @@ import Control.Arrow.Const
import Control.Arrow.Except
import Control.Arrow.Fail
import Control.Arrow.Fix
import Control.Arrow.Frame
import Control.Arrow.Reader
import Control.Arrow.Stack
import Control.Arrow.State
import Control.Arrow.Store
import qualified Control.Arrow.Trans as Trans
import Control.Arrow.WasmStore
import Control.Arrow.Transformer.Kleisli
import Control.Arrow.Transformer.Stack
import Control.Arrow.Trans
......@@ -34,7 +36,9 @@ import Control.Arrow.Transformer.Reader
import Control.Arrow.Transformer.Value
import Control.Arrow.Transformer.Concrete.Failure
import Control.Arrow.Transformer.Concrete.Frame
import Control.Arrow.Transformer.Concrete.Except
import Control.Arrow.Transformer.Concrete.WasmStore
import Control.Arrow.Transformer.State
import Control.Category
......@@ -102,109 +106,7 @@ import System.IO.Unsafe (unsafePerformIO)
-- type Fix (WasmMemoryT c x y) = Fix (Underlying (WasmMemoryT c) x y)
--
--
data WasmStore v = WasmStore {
funcInstances :: Vector FuncInst,
tableInstances :: Vector TableInst,
memInstances :: Vector MemInst,
globalInstances :: Vector v
} deriving (Show, Eq)
emptyWasmStore :: WasmStore v
emptyWasmStore = WasmStore {
funcInstances = Vec.empty,
tableInstances = Vec.empty,
memInstances = Vec.empty,
globalInstances = Vec.empty
}
data FuncInst =
FuncInst {
funcType :: FuncType,
moduleInstance :: ModuleInstance,
code :: Function
}
| HostInst {
funcType :: FuncType
--hostCode :: HostFunction v c
} deriving (Show,Eq)
newtype TableInst = TableInst Wasm.TableInstance deriving (Show,Eq)
newtype MemInst = MemInst (Vector Word8) deriving (Show,Eq)
newtype WasmStoreT v c x y = WasmStoreT (ReaderT Int (StateT (WasmStore v) c) x y)
deriving (Profunctor, Category, Arrow, ArrowChoice, ArrowLift,
ArrowFail e, ArrowExcept e, ArrowConst r, ArrowStore var' val', ArrowRun, ArrowFrame fd val,
ArrowStack st)--, ArrowState (WasmStore v))
instance (ArrowReader r c) => ArrowReader r (WasmStoreT v c) where
ask = lift' ask
local a = lift $ lmap shuffle1 (local (unlift a))
instance (ArrowState s c) => ArrowState s (WasmStoreT v c) where
instance ArrowTrans (WasmStoreT v) where
-- lift' :: c x y -> WasmStoreT v c x y
lift' arr = WasmStoreT (lift' (lift' arr))
instance (ArrowChoice c, Profunctor c) => ArrowWasmStore v (WasmStoreT v c) where
readGlobal =
WasmStoreT $ proc i -> do
WasmStore{globalInstances=vec} <- get -< ()
returnA -< vec ! i
writeGlobal =
WasmStoreT $ proc (i,v) -> do
store@WasmStore{globalInstances=vec} <- get -< ()
put -< store{globalInstances=vec // [(i, v)]}
-- funcCont :: ReaderT Int (StateT (WasmStore v) c) ((FuncType, ModuleInstance, Function),x) y
-- we need ReaderT Int (StateT (WasmStore v) c) (Int, x) y
readFunction (WasmStoreT funcCont) =
WasmStoreT $ proc (i,x) -> do
WasmStore{funcInstances = fs} <- get -< ()
case fs ! i of
FuncInst fTy modInst code -> funcCont -< ((fTy,modInst,code),x)
_ -> returnA -< error "not yet implemented" --hostCont -< ((fTy,code),x)
withMemoryInstance (WasmStoreT f) = WasmStoreT $ local f
instance (ArrowChoice c, Profunctor c) => ArrowMemory Word32 (Vector Word8) (WasmStoreT v c) where
memread (WasmStoreT sCont) (WasmStoreT eCont) = WasmStoreT $ proc (addr, size, x) -> do
WasmStore{memInstances=mems} <- get -< ()
currMem <- ask -< ()
let MemInst vec = mems ! currMem
let addrI = fromIntegral addr
case (addrI+size <= length vec) of
True -> do
let content = Vec.slice addrI size vec
sCont -< (content,x)
False -> eCont -< x
memstore (WasmStoreT sCont) (WasmStoreT eCont) = WasmStoreT $ proc (addr, content, x) -> do
store@WasmStore{memInstances=mems} <- get -< ()
currMem <- ask -< ()
let MemInst vec = mems ! currMem
let addrI = fromIntegral addr
let size = length content
case (addrI+size <= length vec) of
True -> do
let ind = Vec.enumFromN addrI size
put -< (store{memInstances=mems // [(currMem,MemInst $ Vec.update_ vec ind content)]})
sCont -< x
False -> eCont -< x
instance (Arrow c, Profunctor c) => ArrowMemAddress Value Natural Word32 (WasmStoreT v c) where
memaddr = proc (Value (Wasm.VI32 base), off) -> returnA -< (base+ (fromIntegral off))
instance ArrowSerialize Value (Vector Word8) ValueType LoadType StoreType (WasmStoreT v c) where
instance ArrowMemSizable Value (WasmStoreT v c) where
instance ArrowFix (Underlying (WasmStoreT v c) x y) => ArrowFix (WasmStoreT v c x y) where
type Fix (WasmStoreT v c x y) = Fix (Underlying (WasmStoreT v c) x y)
newtype Value = Value Wasm.Value deriving (Show, Eq)
instance (ArrowChoice c) => IsVal Value (ValueT Value c) where
......@@ -335,7 +237,3 @@ instantiate valMod = do
convertFuncs (Wasm.HostInstance t _) = HostInst t
convertMem (Wasm.MemoryInstance _ _) = MemInst Vec.empty -- TODO
convertGlobals _ = Vec.empty -- TODO
deriving instance Show Wasm.TableInstance
deriving instance Eq Wasm.TableInstance
......@@ -5,7 +5,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
module Frame where
module Control.Arrow.Frame where
import Prelude hiding ((.),read)
......@@ -69,29 +69,6 @@ instance (Profunctor c, Arrow c, ArrowFrame fd v c) => ArrowFrame fd v (ReaderT
frameLookup = lift' frameLookup
frameUpdate = lift' frameUpdate
-- | Arrow transformer that adds a frame to a computation.
newtype FrameT fd v c x y = FrameT (ReaderT fd (StateT (Vector v) c) x y)
deriving (Profunctor,Category,Arrow,ArrowChoice,ArrowLift,--ArrowTrans,
ArrowFail e,ArrowExcept e,ArrowConst r,
ArrowStore var' val', ArrowRun, ArrowStack s)
instance (ArrowReader r c) => ArrowReader r (FrameT fd v c) where
-- ask :: (FrameT fd v c) () r
ask = FrameT (ReaderT $ proc (fd, ()) -> ask -< ())
local a = lift $ lmap shuffle1 (local (unlift a))
instance (ArrowChoice c, Profunctor c) => ArrowFrame fd v (FrameT fd v c) where
inNewFrame (FrameT (ReaderT f)) =
FrameT $ ReaderT $ proc (_,(fd, vs, x)) -> do
put -< fromList vs
f -< (fd, x)
frameData = FrameT ask
frameLookup = FrameT $ ReaderT $ proc (_,n) -> do
vec <- get -< ()
returnA -< vec ! fromIntegral n
frameUpdate = FrameT $ ReaderT $ proc (_,(n,v)) -> do
vec <- get -< ()
put -< vec // [(fromIntegral n, v)]
deriving instance (ArrowFrame fd v c) => ArrowFrame fd v (ValueT v2 c)
deriving instance (Profunctor c, Arrow c, ArrowFrame fd v c) => ArrowFrame fd v (ExceptT e c)
......@@ -101,8 +78,3 @@ instance (Monad f, Profunctor c, Arrow c, ArrowFrame fd v c) => ArrowFrame fd v
frameLookup = lift' frameLookup
frameUpdate = lift' frameUpdate
deriving instance (Profunctor c, Arrow c, ArrowFrame fd v c) => ArrowFrame fd v (StackT s c)
instance ArrowFix (Underlying (FrameT fd v c) x y) => ArrowFix (FrameT fd v c x y) where
type Fix (FrameT fd v c x y) = Fix (Underlying (FrameT fd v c) x y)--FrameT fd v (Fix c (fd,(Vector v,x)) (Vector v,y))
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
module Control.Arrow.MemAddress where
import Control.Arrow.Transformer.Concrete.Except
import Control.Arrow.Transformer.Kleisli
import Control.Arrow.Transformer.Reader
import Control.Arrow.Transformer.Stack
import Control.Arrow.Transformer.State
import Control.Arrow.Transformer.Value
class ArrowMemAddress base off addr c where
memaddr :: c (base, off) addr
deriving instance (ArrowMemAddress base off addr c) => ArrowMemAddress base off addr (ValueT val2 c)
deriving instance (ArrowMemAddress base off addr c) => ArrowMemAddress base off addr (ExceptT e c)
instance (ArrowMemAddress base off addr c) => ArrowMemAddress base off addr (KleisliT f c) where
-- TODO
deriving instance (ArrowMemAddress base off addr c) => ArrowMemAddress base off addr (StackT v c)
instance (ArrowMemAddress base off addr c) => ArrowMemAddress base off addr (StateT s c) where
-- TODO
instance (ArrowMemAddress base off addr c) => ArrowMemAddress base off addr (ReaderT r c) where
-- TODO
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
module Control.Arrow.MemSizable where
import Control.Arrow
import Control.Arrow.Trans
import Control.Arrow.Transformer.Concrete.Except
import Control.Arrow.Transformer.Kleisli
import Control.Arrow.Transformer.Reader
import Control.Arrow.Transformer.Stack
import Control.Arrow.Transformer.State
import Control.Arrow.Transformer.Value
import Data.Profunctor
class ArrowMemSizable sz c where
memsize :: c () sz
memgrow :: c (sz,x) y -> c x y -> c (sz,x) y
deriving instance (ArrowMemSizable sz c) => ArrowMemSizable sz (ValueT val2 c)
deriving instance (Arrow c, Profunctor c, ArrowMemSizable sz c) => ArrowMemSizable sz (ExceptT e c)
instance (Monad f, Arrow c, Profunctor c, ArrowMemSizable sz c) => ArrowMemSizable sz (KleisliT f c) where
memsize = lift' memsize
-- TODO
deriving instance (ArrowMemSizable sz c) => ArrowMemSizable sz (StackT v c)
instance (ArrowMemSizable sz c) => ArrowMemSizable sz (StateT s c) where
-- TODO
instance (ArrowMemSizable sz c) => ArrowMemSizable sz (ReaderT r c) where
-- TODO
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
module Control.Arrow.Memory where
import Control.Arrow.Transformer.Concrete.Except
import Control.Arrow.Transformer.Kleisli
import Control.Arrow.Transformer.Reader
import Control.Arrow.Transformer.Stack
import Control.Arrow.Transformer.State
import Control.Arrow.Transformer.Value
class ArrowMemory addr bytes c | c -> addr, c -> bytes where
memread :: c (bytes, x) y -> c x y -> c (addr, Int, x) y
memstore :: c x y -> c x y -> c (addr, bytes, x) y
deriving instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (ValueT val2 c)
deriving instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (ExceptT e c)
instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (KleisliT e c) where
-- TODO
deriving instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (StackT e c)
instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (StateT s c) where
-- TODO
instance (ArrowMemory addr bytes c) => ArrowMemory addr bytes (ReaderT r c) where
-- TODO
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
module Control.Arrow.Serialize where
import Control.Arrow.Transformer.Concrete.Except
import Control.Arrow.Transformer.Kleisli
import Control.Arrow.Transformer.Reader
import Control.Arrow.Transformer.Stack
import Control.Arrow.Transformer.State
import Control.Arrow.Transformer.Value
class ArrowSerialize val dat valTy datDecTy datEncTy c | c -> datDecTy, c -> datEncTy where
decode :: c (val, x) y -> c x y -> c (dat, datdecTy, valTy, x) y
encode :: c (dat, x) y -> c x y -> c (val, valTy, datEncTy, x) y
deriving instance (ArrowSerialize val dat valTy datDecTy datEncTy c) => ArrowSerialize val dat valTy datDecTy datEncTy (ValueT val2 c)
deriving instance (ArrowSerialize val dat valTy datDecTy datEncTy c) => ArrowSerialize val dat valTy datDecTy datEncTy (ExceptT e c)
instance (ArrowSerialize val dat valTy datDecTy datEncTy c) => ArrowSerialize val dat valTy datDecTy datEncTy (KleisliT f c) where
-- TODO
deriving instance (ArrowSerialize val dat valTy datDecTy datEncTy c) => ArrowSerialize val dat valTy datDecTy datEncTy (StackT v c)
instance (ArrowSerialize val dat valTy datDecTy datEncTy c) => ArrowSerialize val dat valTy datDecTy datEncTy (StateT s c) where
-- TODO
instance (ArrowSerialize val dat valTy datDecTy datEncTy c) => ArrowSerialize val dat valTy datDecTy datEncTy (ReaderT r c) where
-- TODO
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Control.Arrow.Transformer.Concrete.Frame where
import Control.Arrow
import Control.Arrow.Const
import Control.Arrow.Except
import Control.Arrow.Fail
import Control.Arrow.Fix
import Control.Arrow.Frame
import Control.Arrow.Reader
import Control.Arrow.Stack
import Control.Arrow.State
import Control.Arrow.Store
import Control.Arrow.Trans
import Control.Arrow.Transformer.Reader
import Control.Arrow.Transformer.State
import Control.Category
import Data.Monoidal (shuffle1)
import Data.Profunctor
import Data.Vector
-- | Arrow transformer that adds a frame to a computation.
newtype FrameT fd v c x y = FrameT (ReaderT fd (StateT (Vector v) c) x y)
deriving (Profunctor,Category,Arrow,ArrowChoice,ArrowLift,--ArrowTrans,
ArrowFail e,ArrowExcept e,ArrowConst r,
ArrowStore var' val', ArrowRun, ArrowStack s)
instance (ArrowReader r c) => ArrowReader r (FrameT fd v c) where
-- ask :: (FrameT fd v c) () r
ask = FrameT (ReaderT $ proc (fd, ()) -> ask -< ())
local a = lift $ lmap shuffle1 (local (unlift a))
instance (ArrowChoice c, Profunctor c) => ArrowFrame fd v (FrameT fd v c) where
inNewFrame (FrameT (ReaderT f)) =
FrameT $ ReaderT $ proc (_,(fd, vs, x)) -> do
put -< fromList vs
f -< (fd, x)
frameData = FrameT ask
frameLookup = FrameT $ ReaderT $ proc (_,n) -> do
vec <- get -< ()
returnA -< vec ! fromIntegral n
frameUpdate = FrameT $ ReaderT $ proc (_,(n,v)) -> do
vec <- get -< ()
put -< vec // [(fromIntegral n, v)]
instance ArrowFix (Underlying (FrameT fd v c) x y) => ArrowFix (FrameT fd v c x y) where
type Fix (FrameT fd v c x y) = Fix (Underlying (FrameT fd v c) x y)--FrameT fd v (Fix c (fd,(Vector v,x)) (Vector v,y))
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
module Control.Arrow.Transformer.Concrete.WasmStore where
import Control.Arrow
import Control.Arrow.Const
import Control.Arrow.Except
import Control.Arrow.Fail
import Control.Arrow.Fix
import Control.Arrow.Frame
import Control.Arrow.MemAddress
import Control.Arrow.Memory
import Control.Arrow.MemSizable
import Control.Arrow.Reader
import Control.Arrow.Serialize
import Control.Arrow.Stack
import Control.Arrow.State
import Control.Arrow.Store
import Control.Arrow.Trans
import Control.Arrow.WasmStore
import Control.Arrow.Transformer.Reader
import Control.Arrow.Transformer.State
import Control.Category
import Data.Monoidal (shuffle1)
import Data.Profunctor
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as Vec
import Data.Word
import Language.Wasm.Interpreter (ModuleInstance,emptyStore,emptyImports)
import qualified Language.Wasm.Interpreter as Wasm
import Language.Wasm.Structure hiding (exports)
import Numeric.Natural (Natural)
import GenericInterpreter (LoadType,StoreType)
newtype Value = Value Wasm.Value deriving (Show, Eq)
data WasmStore v = WasmStore {
funcInstances :: Vector FuncInst,
tableInstances :: Vector TableInst,
memInstances :: Vector MemInst,
globalInstances :: Vector v
} deriving (Show, Eq)
emptyWasmStore :: WasmStore v
emptyWasmStore = WasmStore {
funcInstances = Vec.empty,
tableInstances = Vec.empty,
memInstances = Vec.empty,
globalInstances = Vec.empty
}
data FuncInst =
FuncInst {
funcType :: FuncType,
moduleInstance :: ModuleInstance,
code :: Function
}
| HostInst {
funcType :: FuncType
--hostCode :: HostFunction v c
} deriving (Show,Eq)
newtype TableInst = TableInst Wasm.TableInstance deriving (Show,Eq)
newtype MemInst = MemInst (Vector Word8) deriving (Show,Eq)
newtype WasmStoreT v c x y = WasmStoreT (ReaderT Int (StateT (WasmStore v) c) x y)
deriving (Profunctor, Category, Arrow, ArrowChoice, ArrowLift,
ArrowFail e, ArrowExcept e, ArrowConst r, ArrowStore var' val', ArrowRun, ArrowFrame fd val,
ArrowStack st)--, ArrowState (WasmStore v))
instance (ArrowReader r c) => ArrowReader r (WasmStoreT v c) where
ask = lift' ask
local a = lift $ lmap shuffle1 (local (unlift a))
instance (ArrowState s c) => ArrowState s (WasmStoreT v c) where
instance ArrowTrans (WasmStoreT v) where
-- lift' :: c x y -> WasmStoreT v c x y
lift' arr = WasmStoreT (lift' (lift' arr))
instance (ArrowChoice c, Profunctor c) => ArrowWasmStore v (WasmStoreT v c) where
readGlobal =
WasmStoreT $ proc i -> do
WasmStore{globalInstances=vec} <- get -< ()
returnA -< vec ! i
writeGlobal =
WasmStoreT $ proc (i,v) -> do
store@WasmStore{globalInstances=vec} <- get -< ()
put -< store{globalInstances=vec // [(i, v)]}
-- funcCont :: ReaderT Int (StateT (WasmStore v) c) ((FuncType, ModuleInstance, Function),x) y
-- we need ReaderT Int (StateT (WasmStore v) c) (Int, x) y
readFunction (WasmStoreT funcCont) =
WasmStoreT $ proc (i,x) -> do
WasmStore{funcInstances = fs} <- get -< ()
case fs ! i of
FuncInst fTy modInst code -> funcCont -< ((fTy,modInst,code),x)
_ -> returnA -< error "not yet implemented" --hostCont -< ((fTy,code),x)
withMemoryInstance (WasmStoreT f) = WasmStoreT $ local f
instance (ArrowChoice c, Profunctor c) => ArrowMemory Word32 (Vector Word8) (WasmStoreT v c) where
memread (WasmStoreT sCont) (WasmStoreT eCont) = WasmStoreT $ proc (addr, size, x) -> do
WasmStore{memInstances=mems} <- get -< ()
currMem <- ask -< ()
let MemInst vec = mems ! currMem
let addrI = fromIntegral addr
case (addrI+size <= length vec) of
True -> do
let content = Vec.slice addrI size vec
sCont -< (content,x)
False -> eCont -< x
memstore (WasmStoreT sCont) (WasmStoreT eCont) = WasmStoreT $ proc (addr, content, x) -> do
store@WasmStore{memInstances=mems} <- get -< ()
currMem <- ask -< ()
let MemInst vec = mems ! currMem
let addrI = fromIntegral addr
let size = length content
case (addrI+size <= length vec) of
True -> do
let ind = Vec.enumFromN addrI size
put -< (store{memInstances=mems // [(currMem,MemInst $ Vec.update_ vec ind content)]})
sCont -< x
False -> eCont -< x
instance (Arrow c, Profunctor c) => ArrowMemAddress Value Natural Word32 (WasmStoreT v c) where
memaddr = proc (Value (Wasm.VI32 base), off) -> returnA -< (base+ (fromIntegral off))
instance ArrowSerialize v (Vector Word8) ValueType LoadType StoreType (WasmStoreT v c) where
instance ArrowMemSizable v (WasmStoreT v c) where
instance ArrowFix (Underlying (WasmStoreT v c) x y) => ArrowFix (WasmStoreT v c x y) where
type Fix (WasmStoreT v c x y) = Fix (Underlying (WasmStoreT v c) x y)
deriving instance Show Wasm.TableInstance
deriving instance Eq Wasm.TableInstance
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
module Control.Arrow.WasmStore where
import Control.Arrow
import Control.Arrow.Trans
import Control.Arrow.Transformer.Concrete.Except
import Control.Arrow.Transformer.Kleisli
import Control.Arrow.Transformer.Reader
import Control.Arrow.Transformer.Stack
import Control.Arrow.Transformer.State
import Control.Arrow.Transformer.Value
import Data.Profunctor
import Language.Wasm.Structure hiding (exports)
import Language.Wasm.Interpreter (ModuleInstance(..))
class ArrowWasmStore v c | c -> v where
-- | Reads a global variable. Cannot fail due to validation.
readGlobal :: c Int v
-- | Writes a global variable. Cannot fail due to validation.
writeGlobal :: c (Int, v) ()
-- | Reads a function. Cannot fail due to validation.
--readFunction :: c ((FuncType, ModuleInstance, Function), x) y -> c ((FuncType, HostFunction v c), x) y -> c (Int, x) y
readFunction :: c ((FuncType, ModuleInstance, Function), x) y -> c (Int, x) y
-- | readTable f g h (ta,ix,x)
-- | Lookup `ix` in table `ta` to retrieve the function address `fa`.
-- | Invokes `f (fa, x)` if all goes well.
-- | Invokes `g (ta,ix,x)` if `ix` is out of bounds.
-- | Invokes `h (ta,ix,x)` if `ix` cell is uninitialized.
readTable :: c (Int,x) y -> c (Int,Int,x) y -> c (Int,Int,x) y -> c (Int,Int,x) y
-- | Executes a function relative to a memory instance. The memory instance exists due to validation.
withMemoryInstance :: c x y -> c (Int,x) y
deriving instance (ArrowWasmStore v c) => ArrowWasmStore v (ValueT v2 c)
instance (Profunctor c, Arrow c, ArrowWasmStore v c) => ArrowWasmStore v (StateT s c) where
readGlobal = lift' readGlobal
writeGlobal = lift' writeGlobal