Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between #seq and seq in F#

Tags:

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?

like image 436
Mroik Avatar asked Mar 06 '26 20:03

Mroik


1 Answers

  • 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.
like image 168
Tom Moers Avatar answered Mar 08 '26 18:03

Tom Moers