I'm running into an error when creating a signature file for an F# script file which I can't quite work out.
To replicate, create a new F# class library and add a file, Test.fs:
namespace Signatures
open System
type Test (id : Guid, name : string) =
member this.Id = id
member this.Name = name
This will build fine. Then create a new signature file above it, Test.fsi:
namespace Signatures
open System
type Test =
new : (Guid * String) -> Test
member Id : Guid
member Name : String
This will now not build with the error Module 'Signatures' requires a value 'new : (Guid * String) -> Test
(this is different to the error you get if the constructor signature is different in the two files). The only real documentation I can find on defining constructors in the signature file is MSDN and that deals with parameterless constructors.
If you hover over Test in the .fs file the constructor's signature matches the one in the .fsi file. I've also tried changing the constructor so that it is not implicit with no joy.
I'm using the VS2012 RC, and have tried .Net 4 and 4.5.
It's too long for a comment, so I post it as an answer.
Test
's constructor receives two arguments as its parameters, not one argument which is a tuple. I admit that *
between arguments looks confusing. But the signature Guid -> string -> Test
is even worse than that. Constructors should get some inputs and produce a new type instance. Curried form and partial application don't make sense in the context of constructors.
I think the brackets help clarify here.
type Test (id : System.Guid, name : string) =
member this.Id = id
member this.Name = name
produces new : id:Guid * name:string -> Test
while
type Test (tuple: System.Guid * string) =
let id, name = tuple
member this.Id = id
member this.Name = name
gives me new : tuple:(Guid * string) -> Test
in an FSI session. I use F# 2.0/MonoDevelop 3.0 for the record.
Regarding creating type signatures, I usually send code into F# Interactive and copy produced signatures to fsi
files to avoid mistakes. If the tooltips and F# Interactive show type signatures wrongly on VS2012 RC, you should report at fsbugs (at) microsoft (dot) com.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With