Here's my code:
open System
let places = [ ("Grandchester", 552);
("Cambridge", 117900);
("Prague", 1188126); ]
let statusByPopulation = function
| n when n > 1000000 -> "City"
| n when n > 50000 -> "Town"
| _ -> "Village"
System.Console.WriteLine ( places |> List.map (fun (_, population) -> statusByPopulation population))
let print x =
Console.WriteLine (List.map (fun (_, population) -> statusByPopulation population) x) // what I'm trying to do
let something (x:(string * int) list) =
List.map (fun (_, population) -> statusByPopulation population) x; // checking what kinf of type it returns
let print: (string * int) list -> unit =
Console.WriteLine << List.map (fun (_, population) -> statusByPopulation population) // what I'm not allowed to do
System.Console.ReadKey () |> ignore
I wanted to get familiar with the way the function composition operator worked, but for some reason F# can't find the best possible overload for the function...
In the example where I explicitly state the parameter, it sets the type to be val print : x:('a * int) list -> unit
, so I explicitly set the type in the function with the composition operator <<
hoping I'd get the correct result... I didn't...
I then made the function something
with an explicitly declared type for the parameter, just to see what it'd return... It returns this: val something : x:(string * int) list -> string list
So it most definitely returns a type... a list of strings, which I know Console.WriteLine is capable of printing... So why does it tell me it can't determine the overload?