Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between in .fsx, .fsi and .fs file in F#?

Tags:

f#

So I'm starting to learn F# from the tryfsharp.org and I'm using VS2013. What are the differences of the .fs (source), .fsx (script) and .fsi (signature)?

like image 241
Kenneth Bastian Avatar asked Apr 25 '14 12:04

Kenneth Bastian


People also ask

What is a Fsx file?

Script written in F# (pronounced "F Sharp"), a functional programming language formally introduced by Microsoft with Visual Studio 2010; can be run with the "F# Interactive" component of Visual Studio; used for scripting F# code instead of compiling it.

How do I run an FSX file?

To execute code interactively, simply type code in an . fsx file, select a block of code, and hit Alt + Enter . The selected code will be evaluated, and the result will show up in the FSI window. In Visual Studio, you can also select code and right-click “Execute in Interactive”, but shortcuts are way faster.

How do I run an AF script?

You can start by creating a new "F# Script" (File -> New -> File...) and then start writing some code (in an assorted order). Then you can select some part of the code and evaluate it in the F# Interactive window by perssing [Alt]+[Enter].


1 Answers

.fsx is for individual files intended to run as a script. In particular, in an .fsx file you can use things like #r "Foo.dll" to dynamically load a library and #load "Foo.fsx" to load another script file.
[Edit: and starting with .NET 5, #r "nuget: FooBar" to load a NuGet package.]

.fs is for source files compiled as part of a project.

.fsi is for signature files, they are optional and describe the API of a corresponding .fs file. More detail here.

like image 122
Tarmil Avatar answered Sep 18 '22 11:09

Tarmil