Вопрос

I'm creating a module that will be used by C# code, so I would rather not return the LazyList<> directly. If I did, the C# would have to reference the FSharp.PowerPack, which seems strange.

So I would rather return a IList<>, but when I try to do something like:

let x = LazyList.ofSeq {0..10}
let y = x :> IList<int32>

However, this gives me the error:

The type 'LazyList<int> is not compatible with the type 'IList<int>'

This leads me to believe that LazyList<> does NOT implement IList<>. Is this true?

What am I missing?

Это было полезно?

Решение

It is true, LazyList does not implement the IList interface. It implements IEnumerable though.

[<Sealed>]
type LazyList<'T> =
   interface IEnumerable<'T>
   interface System.Collections.IEnumerable
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top