Type inference works left-to-right. This is where the pipeline operator is useful; if you already know the type of 'fis', then write it as fis |> Seq. Map (fun fi -> fi.Name) and the inference works for you (In general, expressions of the form o.
Property o. Method args require the type of 'o' to be known a priori for most other expressions, when a type is not pinned down the inference system can 'float a constraint' along that can be solved later, but for these cases, there are no constraints of the form 'all types with a property named P' or 'all types with a method named M' (like duck typing) that can be postponed and solved later.So you need that info now, or inference fails immediately. ) See also an overview of type inference in F.
Type inference works left-to-right. This is where the pipeline operator is useful; if you already know the type of 'fis', then write it as fis |> Seq. Map (fun fi -> fi.Name) and the inference works for you.
(In general, expressions of the form o. Property o. Method args require the type of 'o' to be known a priori; for most other expressions, when a type is not pinned down the inference system can 'float a constraint' along that can be solved later, but for these cases, there are no constraints of the form 'all types with a property named P' or 'all types with a method named M' (like duck typing) that can be postponed and solved later.
So you need that info now, or inference fails immediately. ) See also an overview of type inference in F#.
Great clarification. +1 – Jose Basilio May 10 '09 at 5:29 3 I hope they make the type inference more robust. I've already hit a few cases where I had to reorder the methods in a class or I would get too generic type errors.
– gradbot May 10 '09 at 14:49 1 For what its worth, this blog post and some of its comments have a useful explanation of some of F#'s strengths and weaknesses in its type checker: neilmitchell.blogspot. Com/2008/12/… – Juliet May 10 '09 at 19:14.
I have a sequence of FileInfo, but I only care about their string names, so I want a sequence of string. Why is this annotation required? If it is known that fis : seq and that Seq.
Map : ('a -> 'b) -> seq -> seq, then shouldn't it infer that the type of the lambda expression is FileInfo -> 'b, and then, from fi.Name : string, further infer that its type is FileInfo -> string?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.