I suggest we ...

Implement IReadOnlyCollection<'T> in list<'T>

.Net 4.5 has a new type IReadOnlyCollection<'T> and list<'T> (a.k.a. FSharpList<'T>) fits this interface precisely, so I think it should implement it.

Original on VS uservoice: http://visualstudio.uservoice.com/forums/121579/suggestions/2902147

3 votes
Sign in
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Petr Onderka shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

This is approved for inclusion in a future release of the F# core library subject to an implementation.

A pull request to implement this feature will be necessary and we encourage contributors to submit one with adequate design detail and testing to http://github.com/Microsoft/visualfsharp.

Discussion of the particular version where this is included can be started once an implementation is available.

Don Syme, F# Language and Core Library Evolution.


Sign in
Sign in with: facebook google
Signed in as (Sign out)
  • Don Syme commented  ·   ·  Flag as inappropriate

    This seems entirely reasonable (we really should have done it n the FSharp.Core revision)

  • Mauricio Scheffer commented  ·   ·  Flag as inappropriate


    module List =
    let asReadOnlyList (this: _ list) =
    { new System.Collections.Generic.IReadOnlyList<_> with
    member x.GetEnumerator() = (this :> _ seq).GetEnumerator()
    member x.GetEnumerator() = (this :> System.Collections.IEnumerable).GetEnumerator()
    member x.Count = this.Length
    member x.Item with get i = this.[i] }

F# Language

Feedback and Knowledge Base