-
Notifications
You must be signed in to change notification settings - Fork 75
Add basic F# GitHub Copilot instructions and GitHub MCP #726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| We prefer the latest F# 9 features over the old syntax | ||
|
|
||
| Prefer `voption` over `option` | ||
|
|
||
| Prefer `task` CE over `async` CE | ||
|
|
||
| This is how you define a non-default F# class constructor: | ||
| ```fsharp | ||
| type DerivedClass = | ||
| inherit BaseClass | ||
|
|
||
| new (``arguments here``) as ``created object`` | ||
| = | ||
| // create any objects used in the base class constructor | ||
| let fieldValue = "" | ||
| { | ||
| inherit | ||
| BaseClass (``arguments here``) | ||
| } | ||
| then | ||
| ``created object``.otherField <- fieldValue | ||
|
|
||
| [<DefaultValue>] | ||
| val mutable otherField : FieldType | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xperiandri let's not encourage Copilot to use the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually add such a sample to Copilot instructions as neither it knows how to implement non-default constructors, nor I remember.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The mutable keyword can be mentioned separately to bring its attention to the preference of not using it. |
||
| ``` | ||
|
|
||
| Always prefer F# class initializers over property assignment! **You absolutely must use F# class initializers instead of property assignment**! | ||
|
|
||
| Class declaration: | ||
| ``` F# | ||
| type MyClass (someConstructorParam : string) = | ||
| member ReadOnlyProperty = someConstructorParam | ||
|
|
||
| member val MutableProperty1 = "" with get, set | ||
| member val MutableProperty2 = "" with get, set | ||
| ``` | ||
|
|
||
| Wrong: | ||
| ``` F# | ||
| let myClass = MyClass("some value") | ||
| myClass.MutableProperty1 <- "new value" | ||
| myClass.MutableProperty2 <- "new value" | ||
| ``` | ||
|
|
||
| Right: | ||
| ``` F# | ||
| let myClass = | ||
| MyClass( | ||
| // constructor parameters go first without names | ||
| "some value", | ||
| // then mutable properties go next with names | ||
| MutableProperty1 = "new value", | ||
| MutableProperty2 = | ||
| // operations must be placed into parentheses | ||
| (5 |> string) | ||
| ) | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "servers": { | ||
| "GitHub": { | ||
| "type": "http", | ||
| "url": "https://api.githubcopilot.com/mcp/", | ||
| "headers": { | ||
| "Authorization": "Bearer ${input:github_pat}" | ||
| } | ||
| } | ||
| }, | ||
| "inputs": [ | ||
| { | ||
| "id": "github_pat", | ||
| "description": "GitHub personal access token", | ||
| "type": "promptString", | ||
| "password": true | ||
| } | ||
| ] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xperiandri let's put this line backwards, async is idomatic F#