I need to implement a static extension method that supports element restrictions for some basic primitive types, such as integers, floats, etc. Here is my code for signed integers:
module MyOperators = let inline foo (x : ^T) = (^T : (static member Foo : ^T -> int) (x)) type System.Int32 with static member Foo(x : Int32) = 7
Test code:
open MyOperators let x = foo 5
But the compiler complains about the error:
Type "System.Int32" does not support any statements named "Foo"
What am I missing here? Thank!
extension-methods f # type-constraints
Stringer Sep 09 '10 at 10:54 2010-09-09 22:54
source share