How do I override tostring function on a built in collection such as map or sequence such that printfn will use this new custom tostring function?
I would guess it should be something like
type seq<'T> with
override xs.Tostring() =
"blabla"
however this just gives the error "type abbreviations cannot have augmentations".
I then looked at msdn and found following about type extension http://msdn.microsoft.com/en-us/library/dd233211.aspx
it states that I should be able to extend for example int32 and sequence like following
type System.Int32 with
member this.FromString( s : string ) =
System.Int32.Parse(s)
type seq<'T> with
/// Repeat each element of the sequence n times
member xs.RepeatElements(n: int) =
seq { for x in xs do for i in 1 .. n do yield x }
First example works fine however for the second one I just get an error saying "type abbreviations cannot have members".
I am currently using .Net 4.5.1 and F# 3.1