Here's one way:
open System.Collections.Generic
type Node<'a> () =
let getEmptyEnumerator () = Seq.empty<Node<'a>>.GetEnumerator ()
interface IEnumerable<Node<'a>> with
member this.GetEnumerator () = getEmptyEnumerator ()
member this.GetEnumerator () =
getEmptyEnumerator () :> System.Collections.IEnumerator
Instead of returning the empty sequence, you could implement this class to return a sequence of child nodes. I called this type Node<'a>
, because it's a fairly idiomatic way to model a tree (or a graph) in C#.
Use:
> let smth = Something<string, Node<int>> ();;
val smth : Something<string,Node<int>>
> smth.x;;
val it : int = 42
Impossible
, tryCan't get my head around this one
– Yusuklet z = new Something<OpenXmlElement, OpenXmlElement>()
works – Unemployablenew Something<string, seq<string>>()
... which won't work. – Unemployable