tweag / asterius

DEPRECATED in favor of ghc wasm backend, see https://www.tweag.io/blog/2022-11-22-wasm-backend-merged-in-ghc
1.98k stars 57 forks source link

Support FFI based on WebAssembly Interface Types #721

Open serefarikan opened 4 years ago

serefarikan commented 4 years ago

Is your feature request related to a problem? Please describe. I write lots of code in .NET and JVM environments. None of these massive ecosystems offer me a pragmatic way of implementing a purely functional core based on Haskell, which would make calls to existing .NET/JVM libraries for IO etc.

Describe the solution you'd like I'd like to have an FFI layer I can call from Haskell, which would then talk to WASM hosting features of the target platform. See this for .NET and take a look at Graal VM's under-development WASM support for details.

Describe alternatives you've considered Using Purescript and leveraging FFI features of various Javascript runtimes available in .NET and JVM world.

Additional context Convincing my employer, or many other companies with heavy investment into .NET and JVM solutions to completely switch to Haskell is not an option. I also don't necessarily see a complete migration as a sensible strategy for every company. However, having the option of injecting library like functionality in cases where Haskell would make a difference, would be a great middle ground. I think it would also give Haskell developers a whole new set of possibilities for especially IO and using existing eco-systems safely, while non Haskell world keeps improving these libraries. So this is also a suggestion for a new FFI approach for Haskell developers, as much as a suggestion for .NET/JVM developers to leverage Haskell.

Finally, many thanks for such a great piece of work.

serefarikan commented 4 years ago

Am I terribly clueless here? If so, I have no problem with hearing it :) It would be great if I could get any comments at all. Did I get things completely wrong? Is this something already possible and I'm missing it? Something else?