dotnet / dotnet/fsharp

Refactoring for _.Property / _.MethodCall() / _.IndexerAccess[idx] shorthand for accessor functions

Open
#16,234 20 comments 0 reactions 0 assignees View on GitHub
Analyzers Area-LangService-CodeFixes Feature Request
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

Now that https://github.com/dotnet/fsharp/pull/13907 is merged would be good to have code-fix for this

- [Design](https://github.com/fsharp/fslang-design/blob/main/FSharp-8.0/FS-1129-shorthand-anonymous-unary-functions.md#f-rfc-fs-1129---_-shorthand-for-simple-anonymous-unary-functions)
- [Implementation]( https://github.com/dotnet/fsharp/pull/13907)

- From `fun x -> x.Foo` to `_.Foo` and maybe the other way around too ?

```fsharp
// From
let a5 : {| Foo : int -> {| X : string |} |} -> string = fun x -> x.Foo(5).X

// To
let a5 : {| Foo : int -> {| X : string |} |} -> string = _.Foo(5).X

// From
let a6 = [1] |> List.map(fun x -> x.ToString())

// To
let a6 = [1] |> List.map _.ToString()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.