NetCordDev / NetCordDev/NetCord

Provide extensions for F#

Open
#85 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
454
Forks
42
Avg merge
22h 41m
Merged PRs (30d)
14

Description

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 https://github.com/fsharp/fslang-suggestions/issues/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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal API command example using AddSlashCommand and the service extension chain, then identify other service APIs that need FSharpFunc overloads. Review the proposed {PackageName}.FSharp naming, including NetCord.Hosting.FSharp, and determine the complete extension scope. Done means the F# extensions are defined and the minimal API experience no longer requires Func.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, fsharp
Domain
api, developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.