playing with i31

This commit is contained in:
2026-07-11 19:18:35 -06:00
parent f592a4ecbd
commit fdf3064665
2 changed files with 30 additions and 10 deletions
+15 -1
View File
@@ -28,6 +28,10 @@ module Gyehoek.Wasm
, result
, param
, if'
, ref
, eq
, i31ref
, i31
)
where
@@ -59,6 +63,7 @@ import Language.Sexp.Located
import qualified Gyehoek.Sexp
import GHC.IsList (IsList(..))
import Data.Coerce (coerce)
import qualified Control.Category
data Module = MkModule
@@ -160,8 +165,14 @@ execGenMod = fmap snd . runGenMod
renderModule :: Module -> Text
renderModule = (^?! _Right) . Gyehoek.Sexp.encodePretty
i32 :: Type
ref :: Type -> Type
ref (MkType x) = MkType . ParenList $ [Symbol "ref", x]
i32, i31ref, eq, i31 :: Type
i32 = MkType $ Symbol "i32"
i31ref = MkType $ Symbol "i31ref"
eq = MkType $ Symbol "eq"
i31 = MkType $ Symbol "i31"
@@ -206,6 +217,9 @@ instance SexpIso Module where
<> (m ^.. #functions . each . to sxp)
<> (m ^.. #exports . each . to sxp)
instance SexpIso Sexp where
sexpIso = Control.Category.id
instance Each Expr Expr Instr Instr where
each = #MkExpr . each