简体   繁体   中英

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?

  • 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM