Generics with interfaces in F #

In C #, you can specify that a generic parameter should implement a specific interface as follows:

public class Something<T> where T : IComparable { ... } 

How to specify this in F #?

+7
generics interface f #
source share
1 answer

General restrictions use the "when" in F #:

 type Foo<'a when 'a :> IComparable> = member x.Bla = 0 
+10
source share

All Articles