From 388363397a5449be34a889caa1329cc7f884ddfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madeleine=20Sydney=20=C5=9Alaga?= Date: Fri, 17 Jul 2026 13:49:50 -0600 Subject: [PATCH] delete guileslop and add haskellslop --- examples/hs/plain-ghc/Hello.hi | Bin 0 -> 1251 bytes examples/hs/plain-ghc/Hello.hs | 15 ++++ examples/hs/plain-ghc/Hello.o | Bin 0 -> 10623 bytes examples/hs/plain-ghc/Hello_stub.h | 9 +++ examples/hs/plain-ghc/Shakefile.hs | 39 ++++++++++ examples/hs/plain-ghc/call-hello.wat | 6 ++ examples/{ => wat}/addcomponent/adder.wat | 0 examples/{ => wat}/addcomponent/adder.wit | 0 examples/{ => wat}/cont-stack/Shakefile.hs | 0 examples/{ => wat}/cont-stack/cont-stack.wat | 0 examples/{ => wat}/cont-stack/run.js | 0 examples/{ => wat}/hello/Shakefile.hs | 0 examples/{ => wat}/hello/hello.wat | 0 examples/{ => wat}/hello/hello.wit | 0 .../{ => wat}/providecomponent/Shakefile.hs | 0 .../{ => wat}/providecomponent/importing.wat | 0 .../{ => wat}/providecomponent/importing.wit | 0 .../{ => wat}/providecomponent/provider.wat | 0 .../{ => wat}/providecomponent/provider.wit | 0 examples/{ => wat}/silly/Shakefile.hs | 0 examples/{ => wat}/silly/silly.wat | 0 examples/{ => wat}/silly/silly.wit | 0 flake.lock | 73 +++++++++++++++++- flake.nix | 3 +- guile/cps/.gitignore | 2 - guile/cps/Shakefile.hs | 21 ----- guile/cps/t.scm | 3 - 27 files changed, 143 insertions(+), 28 deletions(-) create mode 100644 examples/hs/plain-ghc/Hello.hi create mode 100644 examples/hs/plain-ghc/Hello.hs create mode 100755 examples/hs/plain-ghc/Hello.o create mode 100644 examples/hs/plain-ghc/Hello_stub.h create mode 100644 examples/hs/plain-ghc/Shakefile.hs create mode 100644 examples/hs/plain-ghc/call-hello.wat rename examples/{ => wat}/addcomponent/adder.wat (100%) rename examples/{ => wat}/addcomponent/adder.wit (100%) rename examples/{ => wat}/cont-stack/Shakefile.hs (100%) rename examples/{ => wat}/cont-stack/cont-stack.wat (100%) rename examples/{ => wat}/cont-stack/run.js (100%) rename examples/{ => wat}/hello/Shakefile.hs (100%) rename examples/{ => wat}/hello/hello.wat (100%) rename examples/{ => wat}/hello/hello.wit (100%) rename examples/{ => wat}/providecomponent/Shakefile.hs (100%) rename examples/{ => wat}/providecomponent/importing.wat (100%) rename examples/{ => wat}/providecomponent/importing.wit (100%) rename examples/{ => wat}/providecomponent/provider.wat (100%) rename examples/{ => wat}/providecomponent/provider.wit (100%) rename examples/{ => wat}/silly/Shakefile.hs (100%) rename examples/{ => wat}/silly/silly.wat (100%) rename examples/{ => wat}/silly/silly.wit (100%) delete mode 100644 guile/cps/.gitignore delete mode 100644 guile/cps/Shakefile.hs delete mode 100644 guile/cps/t.scm diff --git a/examples/hs/plain-ghc/Hello.hi b/examples/hs/plain-ghc/Hello.hi new file mode 100644 index 0000000000000000000000000000000000000000..01cd7ce04a6ae63e1fcaeb74885694952c344c80 GIT binary patch literal 1251 zcmZQz{B@4U($K`v$iT?Vz}VP;fq{YL0s{ln7X}8V+YAg$(-;^S85nl-UOIAb=IQwp z77Fmp06b1^V;GcfZo zF!M4n^D!_maxpM4aDvo>^j5GO?!NGR_-f{Wb^S-$=A;xheGcYjh+j4O4 zgdOMZ`JOuX^1#ZSZOgeCm>C!tIFcC|7_Por*}nM8&O^HxPi;E2y=m^&z1|>KFn~2) z`grPb>(rSq>}EEun0nzt`?Ua&4;VO-K{himu!2;wgIoY*g9Y#tfjhsfczt}<^8XVV zkL)>q^X~7vr~DWg7EgQF(DeVtoSMJimaN}!{qvM9jC&6)+TF1D&Yo9{XZ|#7dHnbK z1LxyEzrSp`zifWyx;-E7wH|2RB*(zOpapUZBNGD?KR?Jh3=B*H0w4w>Bjc)uhG!fQ z5*+l5!e1L+ww>R+dbRZPGbbLtXz0A`z`($;jvb__XT{4SYd5^zs{M57%dO|u{@C;s z*yx`VOx)|{K$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q+v90U2G&Vz z2@I@rK&%C9i43f(*pe7n53nUOuwG+JVPJj3X28Juhb^9gbsD=m1H&S2mb}E=R0a-q z$iQGeV-JfQ1ICgNM(An~CL$I~AQpcxgZn~=wH_>p{x)do2P=#VS>eHkzjuap1qVA3 z?m;Zx;D9gC;6$v=-~z9!fGo@4#=0VdhX;8v1}|7WWE}<{jwKkF16CLVMOemrkULGt zoh0Nw5ps_RxdVjU;X&@;NP@Z=&<+i92L`zdA_M6pV(mt|8R__=xvVc|%F~Qdk zfdq|MK%_A%cvTJ?J7{f=Pi8JV`sx_Yy=)o`xLWy)xElF5+xW~#?RiMIk_AZw(!ys& z76CW#*^ouR?R$1)5peUK16c&zy642wxaUF^gSPFtF`M>0$U=~oJuk8lq+!p8Bm`~O z^CJsEn)L$6LXcLyAhHmoQ7?on1ZmR?BMT)#`en#MkQTitT7zB;XM0{8S94y1%+|al z{>Ho%?zX%%yy*^Z%FDpH;Fi2BoC|Kq%fY$ecDy{C3vR|Mz`5X7ydsuHyb?kT-iB9( ziXk`QRp4TX7Q8A#4BmiOLx{oK@9JWZ&I5Y$onbj6XF*YZN@;RxQ86P=K~X+v`Y1I; zH>r||IXxqp-%`)eM9)yq$iT?Vz}VP;H903SFTL2vP|r}$Lbp7zI8(PcC0juwqokyu z*h*hNJ+mYyF-b22GGnEeUzDy7WrGyw>gVK? +#if defined(__cplusplus) +extern "C" { +#endif +extern HsInt32 hello(void); +#if defined(__cplusplus) +} +#endif + diff --git a/examples/hs/plain-ghc/Shakefile.hs b/examples/hs/plain-ghc/Shakefile.hs new file mode 100644 index 0000000..28ac784 --- /dev/null +++ b/examples/hs/plain-ghc/Shakefile.hs @@ -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" + ] diff --git a/examples/hs/plain-ghc/call-hello.wat b/examples/hs/plain-ghc/call-hello.wat new file mode 100644 index 0000000..7b92011 --- /dev/null +++ b/examples/hs/plain-ghc/call-hello.wat @@ -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))) diff --git a/examples/addcomponent/adder.wat b/examples/wat/addcomponent/adder.wat similarity index 100% rename from examples/addcomponent/adder.wat rename to examples/wat/addcomponent/adder.wat diff --git a/examples/addcomponent/adder.wit b/examples/wat/addcomponent/adder.wit similarity index 100% rename from examples/addcomponent/adder.wit rename to examples/wat/addcomponent/adder.wit diff --git a/examples/cont-stack/Shakefile.hs b/examples/wat/cont-stack/Shakefile.hs similarity index 100% rename from examples/cont-stack/Shakefile.hs rename to examples/wat/cont-stack/Shakefile.hs diff --git a/examples/cont-stack/cont-stack.wat b/examples/wat/cont-stack/cont-stack.wat similarity index 100% rename from examples/cont-stack/cont-stack.wat rename to examples/wat/cont-stack/cont-stack.wat diff --git a/examples/cont-stack/run.js b/examples/wat/cont-stack/run.js similarity index 100% rename from examples/cont-stack/run.js rename to examples/wat/cont-stack/run.js diff --git a/examples/hello/Shakefile.hs b/examples/wat/hello/Shakefile.hs similarity index 100% rename from examples/hello/Shakefile.hs rename to examples/wat/hello/Shakefile.hs diff --git a/examples/hello/hello.wat b/examples/wat/hello/hello.wat similarity index 100% rename from examples/hello/hello.wat rename to examples/wat/hello/hello.wat diff --git a/examples/hello/hello.wit b/examples/wat/hello/hello.wit similarity index 100% rename from examples/hello/hello.wit rename to examples/wat/hello/hello.wit diff --git a/examples/providecomponent/Shakefile.hs b/examples/wat/providecomponent/Shakefile.hs similarity index 100% rename from examples/providecomponent/Shakefile.hs rename to examples/wat/providecomponent/Shakefile.hs diff --git a/examples/providecomponent/importing.wat b/examples/wat/providecomponent/importing.wat similarity index 100% rename from examples/providecomponent/importing.wat rename to examples/wat/providecomponent/importing.wat diff --git a/examples/providecomponent/importing.wit b/examples/wat/providecomponent/importing.wit similarity index 100% rename from examples/providecomponent/importing.wit rename to examples/wat/providecomponent/importing.wit diff --git a/examples/providecomponent/provider.wat b/examples/wat/providecomponent/provider.wat similarity index 100% rename from examples/providecomponent/provider.wat rename to examples/wat/providecomponent/provider.wat diff --git a/examples/providecomponent/provider.wit b/examples/wat/providecomponent/provider.wit similarity index 100% rename from examples/providecomponent/provider.wit rename to examples/wat/providecomponent/provider.wit diff --git a/examples/silly/Shakefile.hs b/examples/wat/silly/Shakefile.hs similarity index 100% rename from examples/silly/Shakefile.hs rename to examples/wat/silly/Shakefile.hs diff --git a/examples/silly/silly.wat b/examples/wat/silly/silly.wat similarity index 100% rename from examples/silly/silly.wat rename to examples/wat/silly/silly.wat diff --git a/examples/silly/silly.wit b/examples/wat/silly/silly.wit similarity index 100% rename from examples/silly/silly.wit rename to examples/wat/silly/silly.wit diff --git a/flake.lock b/flake.lock index d212ee9..53e7806 100644 --- a/flake.lock +++ b/flake.lock @@ -1,6 +1,61 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "ghc-wasm": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "host": "gitlab.haskell.org", + "lastModified": 1784272731, + "narHash": "sha256-VcoIdIlUXz7fxu7gXbwih9Wy0m+i2wq6yYsSiFMuDs0=", + "owner": "haskell-wasm", + "repo": "ghc-wasm-meta", + "rev": "ec050b490a8499a1d1d1a3c093b8e760a20d4ebf", + "type": "gitlab" + }, + "original": { + "host": "gitlab.haskell.org", + "owner": "haskell-wasm", + "repo": "ghc-wasm-meta", + "type": "gitlab" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1784182977, + "narHash": "sha256-Hy8zg2HEcsk4WqowQK3UKRXz1fdQM7Z2un3nSyLbJaQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "29c22b7761070f37c4c2b0dd6a8777f0bd43e268", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-26.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1781607440, "narHash": "sha256-rxO+uc/KFbSJp+pgyXRuAX6QlG9hJdnt0BXpEQRXY+U=", @@ -18,7 +73,23 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "ghc-wasm": "ghc-wasm", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 17adf31..81e85af 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,7 @@ { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + ghc-wasm.url = "gitlab:haskell-wasm/ghc-wasm-meta?host=gitlab.haskell.org"; }; outputs = inputs: @@ -19,7 +20,7 @@ pkgs.wasmtime pkgs.wasm-tools pkgs.wac-cli - pkgs.guile + inputs.ghc-wasm.packages.${system}.all_9_14 ]; }; }; diff --git a/guile/cps/.gitignore b/guile/cps/.gitignore deleted file mode 100644 index 395c5c2..0000000 --- a/guile/cps/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.cps -*.go \ No newline at end of file diff --git a/guile/cps/Shakefile.hs b/guile/cps/Shakefile.hs deleted file mode 100644 index 23849e6..0000000 --- a/guile/cps/Shakefile.hs +++ /dev/null @@ -1,21 +0,0 @@ -import Development.Shake -import Development.Shake.Command -import Development.Shake.FilePath -import Development.Shake.Util - -main = shakeArgs shakeOptions $ do - action $ do - sourceFiles <- getDirectoryFiles "" ["//*.scm"] - need $ (-<.> "cps") <$> sourceFiles - "*.cps" %> \out -> do - withTempFile $ \temp_cps -> do - let scm = out -<.> "scm" - need [scm] - cmd_ - "guild compile -O0 -Ocps -t cps -o" [temp_cps] - [scm] - cmd_ (FileStdout out) - (Stdin ";; -*- mode:scheme -*-\n") "cat -" [temp_cps] - phony "clean" $ do - removeFilesAfter ".shake" ["//*"] - liftIO $ removeFiles "." ["*.cps","*.go"] diff --git a/guile/cps/t.scm b/guile/cps/t.scm deleted file mode 100644 index 4c83eb9..0000000 --- a/guile/cps/t.scm +++ /dev/null @@ -1,3 +0,0 @@ -(display "the numberr is ... ") -(display (+ 5 (* 3 4))) -(newline)