Skip to content

Provide extensions for F# #85

@KubaZ2

Description

@KubaZ2

Description

Here is how you would currently write a minimal API style bot in F#:

let builder = Host.CreateApplicationBuilder()

builder.Services
    .AddApplicationCommands()
    .AddDiscordGateway() |> ignore

let host = builder.Build()

host.AddSlashCommand("ping", "Ping!", Func<string>(fun() -> "Pong"))
    .UseGatewayEventHandlers() |> ignore

host.Run()

Currently, Func<string>(...) is needed for minimal API commands. To improve the experience, it would be needed to provide generic overloads with FSharpFunc<...>. This issue would also be resolved by fsharp/fslang-suggestions#1131.

Of course extensions for services themselves would also be added.

I am also probably unaware of other places in which extensions for F# would be needed. Feel free to suggest them.

The package naming would be {PackageName}.FSharp, so for example it would be NetCord.Hosting.FSharp for NetCord.Hosting.

I think it would be better to write the extensions in F#, as only F# methods can be inlined and optimized by the compiler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions