dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.93k stars 788 forks source link

What happens when you introduce parenthesis around tuple declaration in f# signature file? #1344

Closed wallymathieu closed 8 years ago

wallymathieu commented 8 years ago

While trying out things looking at RFC FS-1004 Result type in the following repository, I stumbled on something.

The following compiles (together with an implementation):

[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module Result =
...
  [<Class>]
  type ResultBuilder =
...
    member Combine : (Result<'T,'TError>)* (Result<'T,'TError>) -> Result<('T list),('TError list)>

The implementation:

    member __.Combine (a: Result<'T,'TError>, b:Result<'T,'TError>) : Result<'T list,'TError list>= 
        match a,b with
        | Ok v1,Ok v2 -> Ok [v1;v2]
        | Error e1,Error e2 -> Error [e1;e2]
        | Error e1, _ -> Error [e1]
        | _, Error e2 -> Error [e2]

However, the following does not:

[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module Result =
...
  [<Class>]
  type ResultBuilder =
...
    member Combine : ((Result<'T,'TError>)* (Result<'T,'TError>)) -> Result<('T list),('TError list)>

Note the extra parenthesises around the parameters.

I've tested the behaviour on f# bundled with Mono 4.4.1 and F# 4.0 (F# Compiler version 14.0.23413.0). The .net version used: 4.5.

dsyme commented 8 years ago

@wallymathieu This is by design - the extra parentheses indicate that the method takes an actual tuple value, rather than two arguments.

dsyme commented 8 years ago

@wallymathieu Thanks for the report. Since this is by design, I'll close it.

wallymathieu commented 8 years ago

Aaa, thanks!