Search Results

Search found 2 results on 1 pages for 'fairflow'.

Page 1/1 | 1 

  • F# - When do you use a class instead of a record when you do not want to use mutable fields?

    - by fairflow
    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 type 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?

    Read the article

  • F# - When do you use a type class instead of a record when you do not want to use mutable fields?

    - by fairflow
    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 type 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?

    Read the article

1