delete guileslop and add haskellslop

This commit is contained in:
2026-07-17 13:49:50 -06:00
parent d3cf938eb3
commit 388363397a
27 changed files with 143 additions and 28 deletions
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
module Main where
import Foreign (Int32)
foreign export ccall "hello" hello :: IO Int32
hello :: IO Int32
hello = do
putStrLn "hello from Haskell!!!"
pure 0
main :: IO ()
main = error "defining main shouldn't be necessary since we set -no-hs-main, \
\but HLS is yelling at me and i just want to calm her down."
BIN
View File
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
#include <HsFFI.h>
#if defined(__cplusplus)
extern "C" {
#endif
extern HsInt32 hello(void);
#if defined(__cplusplus)
}
#endif
+39
View File
@@ -0,0 +1,39 @@
import Development.Shake
import Development.Shake.Command
import Development.Shake.FilePath
import Development.Shake.Util
import Data.Char (toUpper)
capitalise (x:xs) = toUpper x : xs
ghcflags =
[ "-no-hs-main"
, "-optl-mexec-model=reactor"
, "-optl-Wl,--export=hello,--export=hs_init"
]
main = shakeArgs shakeOptions $ do
want ["call-hello.wasm","hello.wasm"]
"call-hello.wasm" %> \out -> do
need ["call-hello.wat"]
cmd_ "wasm-tools parse call-hello.wat" "-o" [out]
"hello.wasm" %> \out -> do
need ["Hello.hs"]
cmd_
"wasm32-wasi-ghc"
"Hello.hs" ghcflags
"-o" [out]
phony "run" $ do
need ["call-hello.wasm","hello.wasm"]
cmd_ "wasmtime run"
"--preload" "env=hello.wasm"
"--invoke" "call-hello"
"call-hello.wasm"
phony "clean" $ do
removeFilesAfter ".shake" ["//*"]
liftIO $ removeFiles "."
[ "*.wasm"
, "*.o"
, "*_stub.h"
, "*.hi"
]
+6
View File
@@ -0,0 +1,6 @@
(module
(import "env" "hello" (func $hello (result i32)))
(import "env" "hs_init" (func $hs-init (param i32 i32)))
(func (export "call-hello") (result i32)
(call $hs-init (i32.const 0) (i32.const 0))
(call $hello)))