I'm imagining a situation where you are creating an F# module in a purely functional style. This means objects do not have mutable fields and are not modified in place. I'm assuming for simplicity that there is no need to use .NET objects or other kinds of objects. There are two possible ways of implementing an object-oriented kind of solution: the first is to use classes and the second to use records which have fields of functional type, to implement methods.

I imagine you'd use classes when you want to use inheritance but that otherwise records would be adequate, if perhaps clumsier to express. Or do you find classes more convenient than records in any case?

  • I didn't know F# had type classes, that's awesome! I should take another look at it. Sep 29, 2012 at 8:53
  • Sorry Jörg, I should have just said "classes". F# has generic classes (classes parameterised by type variables) but it does not have type classes proper. See link
    – fairflow
    Sep 29, 2012 at 9:47
  • 3
    FWIW you can emulate typeclasses in F# : code.google.com/p/fsharp-typeclasses Sep 29, 2012 at 18:24

1 Answer 1


MSDN recommends that you use value types for immutable types with "single-value" semantics that have a footprint of 16 bytes or less. This should give you some guidelines to decide.

  • Thanks CesarGon that's useful. However the project I'm working on is using records that are rather larger than that! Are we sure that F# records are actually implemented as value types? They can also have methods attached, which seems surprising in this context. Heap space is a serious limitation for us as well.
    – fairflow
    Feb 18, 2013 at 16:44
  • 4
    @fairflow: According to this stackoverflow.com/questions/5858550/f-records-vs-net-struct, F# records are actually reference types, so I guess value types are of no use to you here.
    – CesarGon
    Feb 18, 2013 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.