List.map fsi speaks well but cannot build

Why does this piece of code work on my fsi but cannot build the project? I am using vs2010 and F # 2.0 ... Any ideas that I am missing something?

let arg = [@"C:\Temp\bin"; @"C:\temp\xml"] arg|> List.map(fun (s) -> printfn "%s" s) 

get error message expecting int, how?

 Error 1 Type mismatch. Expecting a string list -> int but given a string list -> 'a list The type 'int' does not match the type ''a list' C:\Users\Ebru\Documents\Visual Studio 2010\Projects\WinFind\WinFind\Program.fs 
+4
source share
2 answers

I assume that you actually wrote

 [<EntryPoint>] let Main(args) = let arg = [@"C:\Temp\bin"; @"C:\temp\xml"] arg|> List.map(fun (s) -> printfn "%s" s) 

and EntryPoint (e.g. Main() ) should return int.

+7
source

this snippet compiles on my machine, but the mapping seems weird. I think you really want to do this:

 let arg = [@"C:\Temp\bin"; @"C:\temp\xml"] arg|> List.iter (fun s -> printfn "%s" s) 

which matches with:

 let arg = [@"C:\Temp\bin"; @"C:\temp\xml"] arg|> List.iter (printfn "%s") 

Regards, Forki

0
source

Source: https://habr.com/ru/post/1302459/


All Articles