by May 6, 2012
onRecently I tried to build a static generic class in F# but as it seems there is no direct way to do it. To see what I want to build, here is what could look like in C#:
public static class ProcessorUnit<T>
where T : IProcessor
{
public static bool Process(T element)
{
return element.DoWork();
}
}
The closest I could get in F# looks like the following. Since there are no static classes in F# at all you have to use a type with a private constructor and static member definitions: