fsharp / fsharp/fslang-suggestions

non symmetricity between `fun` and `function` for tuple forces usage of parens

Open
#1,336 7 comments 2 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
373
Forks
21
PR merge metrics
No merged PRs in 30d

Description

those are allegedly similar semantically:
```fsharp
fun a -> //...
function a -> //...
```

but for tuple, it doesn't work
```fsharp
fun a,b -> // error FS0010: Unexpected symbol ',' in lambda expression. Expected '->' or other token.
function a,b -> //...
```

I wonder if this can be fixed without ambiguity, because it would be an incomplete lambda in current version of the language and it would reestablish fuller symmetry with `function` construct.

**The existing way of approaching this problem in F# is** to use `function` or wrap with parens.

Maybe a code fix for putting the parens, or turning into `function` would make sense if we can't make this suggestion work / it is rejected on some grounds.

## Pros and Cons

**The advantages of making this adjustment to F# are** semantically more consistent.

**The disadvantages of making this adjustment to F# are** may prevent other constructs in the future.

## Extra information

**Estimated cost (XS, S, M, L, XL, XXL):** M

**Related suggestions:** (put links to related suggestions here)

## Affidavit

Please tick these items by placing a cross in the box:
* [x] This is not a question (e.g. like one you might ask on [StackOverflow](http://stackoverflow.com)) and I have searched StackOverflow for discussions of this issue
* [x] This is a language change and not purely a tooling change.
* [x] This is not something which has obviously "already been decided" in previous versions of F#. I
* [x] I have [searched both open and closed suggestions on this site](http://github.com/fsharp/fslang-suggestions/issues) and believe this is not a duplicate

Please tick all that apply:
* [x] This is not a breaking change to the F# language design
* [ ] I or my company would be willing to help implement and/or test this

## For Readers

If you would like to see this issue implemented, please click the :+1: emoji on this issue. These counts are used to generally order the suggestions by engagement.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no implementation files or tests. Start by reproducing the `fun a,b ->` and `function a,b ->` examples in F# and review the language-design discussion in the seven comments. Done requires an accepted resolution for the ambiguity, along with corresponding compiler behavior and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.