Hi,
the problem is that the function m in your code expects a parameter of type seq<int> and the code gives it a value of type LazyList<int>. The LazyList is of course compatible with seq type, but F# doesn't automatically insert the coertion.

You can either add the coertion explicitly:

1
let n = m (L :> seq<int>)

Or modify the function m, so it accepts any type that implements the seq<int> interface:

1
2
3
4
5
6
 
// parameter is any type that is a subtype of seq<int>
let m (L:'a when 'a :> seq<int>) = Seq.iter (fun x -> ()) L

// The same thing can be written using the '#' shortcut:
let m (L:#seq<int>) = Seq.iter (fun x -> ()) L
By on 8/14/2007 7:08 AM ()

Gah! I had no idea that's what the # meant! (I thought it distinguished parameters from outputs.) Woohoo!

--
Jeff S.

By on 8/14/2007 7:45 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper