News for hackers. Stuff that matters.
Re:F# 4.0 Preview by endeavour on Thursday November 13, 2014 @04:55AM (#8600731)
You've just described the expression problem.

http://c2.com/cgi/wiki?ExpressionProblem

Re:F# 4.0 Preview by achr2 on Thursday November 13, 2014 @08:30AM (#8601373)
I actually think C# (and many OOP languages) gets around this fairly well, by having virtual and extension methods. Many types of functions can be added easily without needing to go back through every inheritor.
Re:F# 4.0 Preview by louthy on Thursday November 13, 2014 @11:57AM (#8602541)
* EDIT - realised I responded with an answer not related to the topic; I'll leave this here as a point-of-reference for the OO side of F# *

Extension methods don't extend the type. They extend the functionality attached to the type.

F# has these too [1] (actually more powerful versions):

The thing about using sum-types (the original Shape example) is that they're not supposed to be extended. You're defining the range of the type, which allows for powerful inference of completeness when using them. If you need extensible classes then F# can do those too, it can represent interfaces, abstract classes and concrete classes [2][3][4], and can even generate ad-hoc classes from an interface by using Object Expressions [5].

I personally try to stick to the pure functional approach, but it can be very handy when interoperating with the .NET framework, or other C# based libraries.

[1] http://fsharpforfunandprofit.com/posts/type-extensions/

[2] http://fsharpforfunandprofit.com/posts/classes/

[3] http://fsharpforfunandprofit.com/posts/inheritance/

[4] http://fsharpforfunandprofit.com/posts/interfaces/

[5] http://fsharpforfunandprofit.com/posts/object-expressions/