wit-bindgen icon indicating copy to clipboard operation
wit-bindgen copied to clipboard

First class support for F#

Open lukechu10 opened this issue 4 months ago • 3 comments

It would be nice if wit-bindgen could have first class support for F#. Since wit-bindgen already supports C#, I've managed to come up with something a little hacky so that F# can call imported functions defined in WIT (https://github.com/bytecodealliance/componentize-dotnet/issues/92).

However, this approach is not only rather cumbersome, it also does not allow exporting functions from F#.

Since wit-bindgen already supports C#, naively I would expect adding F# support should not be so difficult, but would be more of a matter of just adjusting the C# syntax to F#.

lukechu10 avatar Aug 22 '25 18:08 lukechu10

Are you looking for all the generated code to be in F#, or a c# project that can be built and referenced from F# would be ok?

yowl avatar Aug 22 '25 18:08 yowl

I'm looking for all the generated code to be in F#. I've managed to get the generated C# code working in F# to a certain extent (see the issue I linked) but there isn't a nice way to have F# export functions to WIT.

lukechu10 avatar Aug 22 '25 19:08 lukechu10

Taking a closer look at the code, it seems like this is indeed a little harder than I thought. A lot of C# things such as the generated Result type would probably be better represented in F# using discriminated unions and so on...

Also other things like formatting since F# is a whitespace-sensitive language.

lukechu10 avatar Aug 22 '25 19:08 lukechu10