Hi folks, I'm reading about F# and trying to apply it to my daily job.
I was already been able to load a CSV file with the help of FSharp.Data
from NuGet, but I did it a imperative style, I think. Now I'm trying to apply functional constructs, tried the following:
open System
open System.IO
open FSharp.Data
[<EntryPoint>]
let main argv =
let data =
argv.[0]
|> Path.Combine Environment.CurrentDirectory
|> CsvFile.Load
printfn "%A" data.Headers
0
What I'm missing here?
In my head argv.[0]
is passed to the result of Path.Combine Environment.CurrentDirectory
which curried already have the current dir as the first path
then the combined result is given to CsvFile.Load
.
Did I get |>
and curring wrong?
CsvFile.Load
is probably ok
dotnet build
dotnet test FSharpSuite.Tests.fsproj
@sergey-tihon
A) I should make the tests pass by mimicking the current compiler output? Scenario in which we want to limit future regressions having current state as a base. But we lose the intended behavior of the compiler declared in the old tests.
B) I'm doing things wrong by concatenating the Expectations from old tests. In this case how should I do?
Also the fsi thing you mentioned, can you help me get started? There is a fsx script somewhere?
This is a workaround if you cannot debug / run from VS.
You can start new instance of F# interactive, copy-paste the code snipped from your test and it will point you 1st waring/error
(int, string) Map
you'll get a compiler warning: "warning FS0062: This construct is for ML compatibility. The syntax '(typ,...,typ) ident' is not used in F# code. Consider using 'ident<typ,...,typ>' instead. You can disable this warning by using '--mlcompatibility' or '--nowarn:62'." So while you can do it, you probably shouldn't since (int, string) Map
doesn't gain any particular readability benefits over Map<int, string>
IMHO. (Whereas int list
flows naturally like English, so it's more readable at a glance than list<int>
).