For instance, in this (very simple example) code I have a member in the class, and a module, which both deal with the same type:
open System
type Thingy(parameter: int) =
member val Parameter = parameter
override this.ToString() =
this.Parameter
|> string
module Thingy =
let asBackwardsString thingy =
thingy.ToString()
|> Seq.rev
|> String.Concat
let value = Thingy(1234)
let str = value.ToString()
let back = value |> Thingy.asBackwardsString
Is it ‘reasonable’ to do this or should I normally keep to one or the other.
I’m guessing that it’s probably a case-by-case-basis thing but was wondering if there were any major potential pitfalls that I would need to keep an eye out for.
Note 1: (I think) I need to create a class in the first place because the real type is implementing the IEquatable and IComparable interfaces.
Note 2: Also, the code will only be accessed from other F# code so there aren’t any interop requirements.