I see that Seq has a cast function from IEnumerable to Seq, but how do I get it to work?
open System.Text.RegularExpressions;;
let v = Regex.Match("abcd", "(ab)");;
Seq.cast (v.Captures);;
This produces,
error FS0030: Value restriction. The value ‘it’ has been inferred to have generic type
val it : seq<‘_a>
Either define ‘it’ as a simple data term, make it a function with explicit arguments or, if you do not intend for it to be generic, add a type annotation.
Be explicit about the type:
Otherwise
castneeds context to infer the right return type, and on a line by itself like there, there is no such context for type inference to use.(This line converts the non-generic
IEnumerableinto a genericIEnumerable<Match>a.k.a.seq<Match>.)