F #: differences between functions and static elements

Can someone explain this to me:

type IItem = interface end
type Item = {i:int} interface IItem

type Fail = static member foo (s:string) = fun (x:IItem) -> ""
let foo = fun (s:string) -> fun (x:IItem) -> ""

let works = {i=1} |> foo ""
let fails = {i=1} |> Fail.foo ""

Why doesn't currying with a static member function work? I am using Visual Studio 2012 with .net 4.5.2 if that matters.

+4
source share
1 answer

This is actually not the difference between static members and functions - it is a bit more subtle. Here's another review:

type T =
    static member A () (o:obj) = ()
    static member B () = fun (o:obj) -> ()

T.A () 1 // ok
T.B () 1 // huh?

Please note that the signatures T.Aand T.Bdifferent (it really is described in section 11.2.1.1 specification):

type T =
  class
    static member A : unit -> o:obj -> unit
    static member B : unit -> (obj -> unit)
  end

, , , .NET A ( F #), B , F #. , , , .

+2

All Articles