Mroik
Mroik

Reputation: 33

Difference between #seq and seq in F#

I was wondering what #seq means in the F# interactive shell. I had a collect function with 2 parameters, a function and a sequence, where this function is applied to the sequence.

let rec collect f sq =
  seq {
    let a = Seq.item 0 sq
    let sq1 = Seq.skip 1 sq
    let ris = f a
    yield! ris
    yield! collect f sq1
  }

When the shell evaluates the collect it gives back the following signature

val collect: f: ('a -> #seq<'c>) -> sq: seq<'a> -> seq<'c>

What does # mean before seq in this instance?

Upvotes: 3

Views: 192

Answers (1)

Tom Moers
Tom Moers

Reputation: 1261

  • seq<'a> is the F# spelling for IEnumerable<T>
  • The # before a type is a flexible type annotation. This allows you to use any type that implements the indicated interface.

Upvotes: 3

Related Questions