In Haskell it is easy to make an algebraic type/discriminated union "displayable" as a string by simply adding deriving Show
to the type definition.
In F# I end up writing things like:
type Pos =
| Pos of int * int
override this.ToString() =
match this with
Pos(startp, endp) -> sprintf "Pos(%d, %d)" startp endp
and obviously it gets much worse with more complicated types.
Any way to get something like deriving Show
in F#?
deriving Show
. – Indevout