I think you want FSI (F # Interactive) called fsharpi
on Linux / MacOS. You can also use fsharpc
, which will compile it, but if you are just trying, testing or creating scripts, then you can find it here .
Note that you must at least install Mono before you can do anything with F # on Linux.
EDIT: As an illustration, the program you mentioned in C can be expressed in a variety of ways, here is one way (which assumes the correct input or exception, the program has not been verified):
[<EntryPoint>] let main argv = let scani() = printfn "Give a number: " Console.ReadLine() |> Int64.Parse let (x, y) = (scani(), scani()) printfn "The sum of %d and %d is %d" xy (x + y)
EDIT 2: You edited your question and expressed a desire to work with Nano. This is an editor I do not know. You also say that you do not want to use Mono. I donβt know why this is so if you do not mean MonoDevelop, because without Mono you cannot compile a .NET program on Linux.
The gcc mySum.c -o mySum
command you gcc mySum.c -o mySum
can be converted to the command line option for F #. For example (given the same syntax as for fsc.exe
) (for greater clarity on several lines):
fsharpc.exe -o:MyProgram.exe --debug:pdbonly --noframework --optimize+ --platform:anycpu32bitpreferred -r:"PathTo\FSharp.Core.dll" -r:"PathTo\mscorlib.dll" -r:"PathToYourReferencedOtherDlls\SomeClassLib.dll -r:"PathTo\System.Core.dll" -r:"PathTo\System.dll" --target:exe --warn:3 file1.fs file2.fs file3.fs
Many of these options may be omitted, but this is a valid command taken from Visual Studio.
I would suggest using an editor that is preconfigured to run F # programs, which has an integrated REPL, as well as a debugger, syntax coloring, live type information (very important!), And other intellisense functions that you get with Visual Studio ( VS version Code runs on Linux and has a great editor, kindly provided by Guy Coder to remind me) and maybe some other F # editors are included.