Hello,
I am new to F# (and .Net). Never programmed in C# or on dotnet. Just started learning F# about a month or so back to explore using it, since it can be now used on Mac and Linux.
I was trying to see if I can use a C# library, Cocona from F#.
For now I am wondering how to translate the following code example from the Github page of the library to F#.
var builder = CoconaApp.CreateBuilder();
var app = builder.Build();
app.AddCommand((string name) => {
Console.WriteLine($"Hello {name}");
});
app.Run();
I created an F# project and added CoconaLite
to the project using dotnet add
command. Then I typed the following:
let builder = CoconaLiteApp.CreateBuilder();
let app = builder.Build();
app.AddCommand (fun (name: string) -> printfn "My name is {name}." |> ignore)
app.Run()
If I try to do this, I get he following error:
error FS0041: No overloads match for method 'AddCommand'.Known type of argument:
(string -> unit)Available overloads: - (extension)
Builder.ICoconaCommandsBuilder.AddCommand(commandBody: Delegate) :
Builder.CommandConventionBuilder // Argument 'commandBody' doesn't match -
(extension) Builder.ICoconaCommandsBuilder.AddCommand(commandData:
Builder.ICommandData) : Builder.ICoconaCommandsBuilder // Argument 'commandData'
doesn't match
[/Users/curioustolearn/LearnSoftware_and_Math/LearnFsharp/App1/App1.fsproj]
The build failed. Fix the build errors and run again.
The build failed. Fix the build errors and run again.
Can someone please let me know if it is possible to use a C# library like Cocona from F#, and a simple example of how to achieve what I am trying to do above. Any link to a resource or example that helps with this question would be helpful too.
Thank you very much.