简体   繁体   中英

F# LazyList -> IList

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

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