delete guileslop and add haskellslop

This commit is contained in:
2026-07-17 14:11:50 -06:00
parent d3cf938eb3
commit 388363397a
27 changed files with 143 additions and 28 deletions
+32
View File
@@ -0,0 +1,32 @@
import Development.Shake
import Development.Shake.Command
import Development.Shake.FilePath
import Development.Shake.Util
main = shakeArgs shakeOptions $ do
-- action $ do
-- sourceFiles <- getDirectoryFiles "" ["//*.luasm"]
-- need $ (-<.> "luac") <$> sourceFiles
want ["hello.component.wasm"]
alternatives $ do
"*.component.wasm" %> \out -> do
let wasm = out `replaceExtensions` "wasm"
need [wasm]
cmd_
"wasm-tools component new"
[wasm]
"-o" [out]
"*.wasm" %> \out -> do
let wit = out -<.> "wit"
let wat = out -<.> "wat"
need [wit,wat]
cmd_
"wasm-tools component embed"
[wit] [wat] "-o" [out]
phony "run" $ do
need ["hello.component.wasm"]
-- cmd_ "wasmtime run --invoke hello() hello.component.wasm"
cmd_ "wasmtime run hello.component.wasm"
phony "clean" $ do
removeFilesAfter ".shake" ["//*"]
liftIO $ removeFiles "." ["*.wasm"]
+23
View File
@@ -0,0 +1,23 @@
(module
;; Correct module name: stdio, not stdout
(import "wasi:cli/stdout@0.2.6" "get-stdout"
(func $get-stdout (result i32)))
;; Write and flush a buffer.
(import
"wasi:io/streams@0.2.6"
"[method]output-stream.blocking-write-and-flush"
(func $print (param i32 i32 i32 i32)))
(memory 1)
(export "memory" (memory 0))
(data (i32.const 16) "hello worms\n")
(func (export "wasi:cli/run@0.2.6#run") (result i32)
(call $print
(call $get-stdout)
(i32.const 16) ;; offset to print
(i32.const 12) ;; length to print
(i32.const 32)) ;; offset for result
(i32.const 0)))
+49
View File
@@ -0,0 +1,49 @@
package root:component;
world root {
import wasi:cli/stdin@0.2.6;
import wasi:cli/stdout@0.2.6;
import wasi:io/streams@0.2.6;
export wasi:cli/run@0.2.6;
}
package wasi:cli@0.2.6 {
interface stdout {
use wasi:io/streams@0.2.6.{output-stream};
get-stdout: func() -> output-stream;
}
interface stdin {
}
interface run {
run: func () -> result;
}
}
package wasi:io@0.2.6 {
interface poll {
resource pollable {
block: func();
}
}
interface error {
resource error;
}
interface streams {
use error.{error};
use poll.{pollable};
resource input-stream;
resource output-stream {
write: func(contents: list<u8>) -> result<_, stream-error>;
blocking-write-and-flush: func(contents: list<u8>) ->result<_,stream-error>;
}
variant stream-error {
last-operation-failed(error),
closed,
}
}
}