Can a function of type (unit -> unit) have statically resolved type parameters in F#?

As you noticed, F# treats the sequence of characters as an infix operator, so you need to separate them with a space. As to the question of when you need to explicitly specify constraints, I believe that the rule is that when you explicitly give a function type parameters then you also need to specify any necessary constraints. Otherwise, if F# can infer the type parameters and constraints, you don't need to specify them So this example from your question works fine: let inline bar() :^a = (^a : (static member Bar : unit -> ^a)()) as would this: let inline bar(x : ^a) = (^a : (static member Bar : unit -> unit)()) because there's a generic type parameter, but you haven't explicitly placed it on the function, and F# can infer the needed constraint On the other hand, if you try to modify your other example to omit the explicit generic parameter: let inline bar() = (^a : (static member Bar : unit -> unit)()) You'll see that F# won't allow this because there's no way for it to figure out how to instantiate a for any given call of bar() Thus, you need to provide the type parameter explicitly, and once you do, you also have to explicitly provide the constraint.

As you noticed, F# treats the sequence of characters ^a)()) as would this: let inline bar(x : ^a) = (^a : (static member Bar : unit -> unit)()) because there's a generic type parameter, but you haven't explicitly placed it on the function, and F# can infer the needed constraint. On the other hand, if you try to modify your other example to omit the explicit generic parameter: let inline bar() = (^a : (static member Bar : unit -> unit)()) You'll see that F# won't allow this because there's no way for it to figure out how to instantiate ^a for any given call of bar(). Thus, you need to provide the type parameter explicitly, and once you do, you also have to explicitly provide the constraint.

Figured it out. Spaces inside the angle brackets are needed, along with a constraint. This works: type Foo() = static member Bar() = () let inline bar unit) >() = (^a : (static member Bar : unit -> unit)()) let _ = bar() From this we can surmise that the constraint is optional if the function returns an instance of the statically resolved type.

Does anyone know if that's the rule?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions