Published on

Is it possible to use dotnet-wasi-sdk with F#?

Authors
  • Name
    Naito Oshima
    Twitter

Is it possible to use dotnet-wasi-sdk with F#?

Yes. F# is based on .NET infrastructure as same as C#. Therefore, you can use the dotnet-wasi-sdk and run the application with a wasm runtime such us wasmtime. However, please note that dotnet-wasi-sdk is an experimental project.

How-to : Hello World based on F# with dotnet-wasi-sdk

Prerequisite :

Procedure:

dotnet new console -lang F# -o FSharpHelloWasm -f net7.0
cd FSharpHelloWasm
dotnet build
wasmtime .\bin\Debug\net7.0\MyFSharpApp.wasm

Output :

> wasmtime .\bin\Debug\net7.0\MyFSharpApp.wasm
Hello from F#

Summary

You can use dotnet-wasi-sdk as well as C#. So, You can run your application on a wasm runtime. However, since this is the experimental project, I'm not sure exactly how well it will work. It is recommended not to use this in production both C# and F#.