I want to create my own custom collection type.
I define my collection as:
type A(collection : seq<string>) =
member this.Collection with get() = collection
interface seq<string> with
member this.GetEnumerator() = this.Collection.GetEnumerator()
But this doesn’t compile No implementation was given for 'Collections.IEnumerable.GetEnumerator()
How do i do this?
In F#
seqis really just an alias forSystem.Collections.Generic.IEnumerable<T>. The genericIEnumerable<T>also implements the non-genericIEnumerableand hence your F# type must do so as well.The easiest way is to just have the non-generic one call into the generic one