Reputation: 330
In C# one can state that a generic parameter must implement a certain interface like so:
public class Something<T> where T : IComparable
{
...
}
How does one specify this in F#?
Upvotes: 8
Views: 1009
Reputation: 10006
Generic constraints use "when" in F#:
type Foo<'a when 'a :> IComparable> =
member x.Bla = 0
Upvotes: 10