diff --git a/.openpublishing.redirection.json b/.openpublishing.redirection.json index 3d16341d1140c..8653340f80aae 100644 --- a/.openpublishing.redirection.json +++ b/.openpublishing.redirection.json @@ -12971,6 +12971,10 @@ "source_path": "docs/fsharp/language-reference/asynchronous-workflows.md", "redirect_url": "/dotnet/fsharp/docs/fsharp/language-reference/async-expressions" }, + { + "source_path": "docs/fsharp/language-reference/structures.md", + "redirect_url": "/dotnet/fsharp/docs/fsharp/language-reference/structs" + }, { "source_path": "docs/fsharp/getting-started-netcore.md", "redirect_url": "/dotnet/fsharp/get-started/get-started-command-line" @@ -13091,11 +13095,15 @@ }, { "source_path": "docs/fsharp/using-fsharp-on-azure/using-fsharp-on-azure-service-fabric.md", - "redirect_url": "/dotnet/fsharp/using-fsharp-on-azure/index" + "redirect_url": "/dotnet/fsharp" }, { "source_path": "docs/fsharp/using-fsharp-on-azure/package-management.md", - "redirect_url": "/dotnet/fsharp/using-fsharp-on-azure/index" + "redirect_url": "/dotnet/fsharp" + }, + { + "source_path": "docs/fsharp/using-fsharp-on-azure/index.md", + "redirect_url": "/dotnet/fsharp" }, { "source_path": "docs/fsharp/whats-new/index.md", diff --git a/docs/fsharp/get-started/get-started-visual-studio.md b/docs/fsharp/get-started/get-started-visual-studio.md index 4bd31425bfba2..d1b7a7d594780 100644 --- a/docs/fsharp/get-started/get-started-visual-studio.md +++ b/docs/fsharp/get-started/get-started-visual-studio.md @@ -58,13 +58,13 @@ Congratulations! You've created your first F# project in Visual Studio, written ## Next steps -If you haven't already, check out the [Tour of F#](../tour.md), which covers some of the core features of the F# language. It provides an overview of some of the capabilities of F# and ample code samples that you can copy into Visual Studio and run. +If you haven't already, check out the [Tour of F#](../tour.md), which covers some of the core features of F#. It provides an overview of some of the capabilities of F# and ample code samples that you can copy into Visual Studio and run. > [!div class="nextstepaction"] > [Tour of F#](../tour.md) ## See also -- [F# language reference](../language-reference/index.md) +- [F# language guide](../language-reference/index.md) - [Type inference](../language-reference/type-inference.md) - [Symbol and operator reference](../language-reference/symbol-and-operator-reference/index.md) diff --git a/docs/fsharp/get-started/get-started-with-visual-studio-for-mac.md b/docs/fsharp/get-started/get-started-with-visual-studio-for-mac.md index 0c3018bbaad61..428c624bdc219 100644 --- a/docs/fsharp/get-started/get-started-with-visual-studio-for-mac.md +++ b/docs/fsharp/get-started/get-started-with-visual-studio-for-mac.md @@ -105,12 +105,12 @@ This is only a glimpse into what you can do with F# Interactive. To learn more, ## Next steps -If you haven't already, check out the [Tour of F#](../tour.md), which covers some of the core features of the F# language. It will give you an overview of some of the capabilities of F#, and provide ample code samples that you can copy into Visual Studio for Mac and run. There are also some great external resources you can use, showcased in the [F# Guide](../index.yml). +If you haven't already, check out the [Tour of F#](../tour.md), which covers some of the core features of F#. It will give you an overview of some of the capabilities of F#, and provide ample code samples that you can copy into Visual Studio for Mac and run. There are also some great external resources you can use, showcased in the [F# Guide](../index.yml). ## See also - [F# guide](../index.yml) - [Tour of F#](../tour.md) -- [F# language reference](../language-reference/index.md) +- [F# language guide](../language-reference/index.md) - [Type inference](../language-reference/type-inference.md) - [Symbol and operator reference](../language-reference/symbol-and-operator-reference/index.md) diff --git a/docs/fsharp/index.yml b/docs/fsharp/index.yml index 07c09fa2a43d3..60fd581bf3f1f 100644 --- a/docs/fsharp/index.yml +++ b/docs/fsharp/index.yml @@ -9,7 +9,7 @@ metadata: ms.topic: landing-page # Required author: cartermp ms.author: phcart - ms.date: 10/29/2021 + ms.date: 11/03/2021 landingContent: - title: "Learn to program in F#" @@ -37,75 +37,101 @@ landingContent: - text: Download the .NET SDK url: https://dotnet.microsoft.com/download + - title: "F# language guide" + linkLists: + - linkListType: overview + links: + - text: "F# language guide" + url: language-reference/index.md + - linkListType: reference + links: + - text: "F# language specification" + url: https://fsharp.org/specs/language-spec/ + - text: "F# RFCs" + url: https://github.com/fsharp/fslang-design + - text: "F# library reference" + url: https://fsharp.github.io/fsharp-core-docs + - text: ".NET library reference" + url: ../../api/index.md?view=net-6.0 + - title: "F# fundamentals" linkLists: - linkListType: overview links: + - text: "Overview" + url: language-reference/index.md - text: "Tour of F#" url: tour.md + - text: "Values" + url: language-reference/values/index.md - linkListType: concept links: - - text: "F# style guide" - url: style-guide/index.md - - text: "F# code formatting guidelines" - url: style-guide/formatting.md - - text: "F# coding conventions" - url: style-guide/conventions.md + - text: "Types and inference" + url: language-reference/fsharp-types.md + - text: "Functional concepts" + url: tutorials/functional-programming-concepts.md + - text: "Type providers" + url: tutorials/type-providers/index.md - linkListType: tutorial links: - - text: "Functional programming concepts in F#" - url: tutorials/functional-programming-concepts.md - - text: "Using Functions in F#" + - text: "Using Functions" url: tutorials/using-functions.md - - text: "Async programming in F#" + - text: "Pattern matching" + url: language-reference/pattern-matching.md + - text: "Object programming" + url: language-reference/index.md#object-programming + - text: "Async programming" url: tutorials/async.md - - text: "Type providers" - url: tutorials/type-providers/index.md - - title: "New features in F#" + - title: "F# in practice" linkLists: - - linkListType: whats-new + - linkListType: overview links: - - text: "What's new in F# 6" - url: whats-new/fsharp-6.md - - text: "What's new in F# 5" - url: whats-new/fsharp-50.md - - text: "What's new in F# 4.7" - url: whats-new/fsharp-47.md - - text: "What's new in F# 4.6" - url: whats-new/fsharp-46.md - - text: "What's new in F# 4.5" - url: whats-new/fsharp-45.md - - - title: "F# language reference" - linkLists: - - linkListType: reference + - text: "F# for web development" + url: scenarios/web-development.md + - text: "F# for machine learning" + url: scenarios/machine-learning.md + - text: "F# for Apache Spark on Azure" + url: using-fsharp-on-azure/apache-spark.md + - text: "F# for deploying Azure resources" + url: using-fsharp-on-azure/deploying-and-managing.md + - linkListType: learn links: - - text: "Language reference" - url: language-reference/index.md - - text: "Keyword reference" - url: language-reference/keyword-reference.md - - text: "Symbol and operator reference" - url: language-reference/symbol-and-operator-reference/index.md - - text: "Functions" - url: language-reference/functions/index.md - - text: "Types" - url: language-reference/fsharp-types.md + - text: "F# style guide" + url: style-guide/index.md + - text: "F# code formatting guidelines" + url: style-guide/formatting.md + - text: "F# coding conventions" + url: style-guide/conventions.md - title: "F# tools" linkLists: - - linkListType: reference + - linkListType: overview links: - text: "F# Interactive" url: tools/fsharp-interactive/index.md - text: "F# development tools" url: https://dotnet.microsoft.com/languages/fsharp/tools + - text: "F# notebooks" + url: tools/notebooks.md + - text: "F# for JavaScript" + url: tools/javascript.md - - title: "F# library reference" + - title: "New features in F#" linkLists: - - linkListType: reference + - linkListType: whats-new links: - - text: "F# core library reference" - url: https://fsharp.github.io/fsharp-core-docs - - text: ".NET library reference" - url: ../../api/index.md?view=net-5.0 + - text: "What's new in F# 6" + url: whats-new/fsharp-6.md + - text: "What's new in F# 5" + url: whats-new/fsharp-50.md + - text: "What's new in F# 4.7" + url: whats-new/fsharp-47.md + - linkListType: tutorial + links: + - text: "Explore tasks" + url: language-reference\task-expressions.md + - text: "Explore interpolated strings" + url: language-reference\interpolated-strings.md + - text: "Explore anonymous records" + url: language-reference\anonymous-records.md diff --git a/docs/fsharp/language-reference/abstract-classes.md b/docs/fsharp/language-reference/abstract-classes.md index e946a204e5fa0..9a08e21bbea62 100644 --- a/docs/fsharp/language-reference/abstract-classes.md +++ b/docs/fsharp/language-reference/abstract-classes.md @@ -24,7 +24,7 @@ abstract member member-name : type-signature In object-oriented programming, an abstract class is used as a base class of a hierarchy, and represents common functionality of a diverse set of object types. As the name "abstract" implies, abstract classes often do not correspond directly onto concrete entities in the problem domain. However, they do represent what many different concrete entities have in common. -Abstract classes must have the `AbstractClass` attribute. They can have implemented and unimplemented members. The use of the term *abstract* when applied to a class is the same as in other .NET languages; however, the use of the term *abstract* when applied to methods (and properties) is a little different in F# from its use in other .NET languages. In F#, when a method is marked with the `abstract` keyword, this indicates that a member has an entry, known as a *virtual dispatch slot*, in the internal table of virtual functions for that type. In other words, the method is virtual, although the `virtual` keyword is not used in the F# language. The keyword `abstract` is used on virtual methods regardless of whether the method is implemented. The declaration of a virtual dispatch slot is separate from the definition of a method for that dispatch slot. Therefore, the F# equivalent of a virtual method declaration and definition in another .NET language is a combination of both an abstract method declaration and a separate definition, with either the `default` keyword or the `override` keyword. For more information and examples, see [Methods](./members/methods.md). +Abstract classes must have the `AbstractClass` attribute. They can have implemented and unimplemented members. The use of the term *abstract* when applied to a class is the same as in other .NET languages; however, the use of the term *abstract* when applied to methods (and properties) is a little different in F# from its use in other .NET languages. In F#, when a method is marked with the `abstract` keyword, this indicates that a member has an entry, known as a *virtual dispatch slot*, in the internal table of virtual functions for that type. In other words, the method is virtual, although the `virtual` keyword is not used in F#. The keyword `abstract` is used on virtual methods regardless of whether the method is implemented. The declaration of a virtual dispatch slot is separate from the definition of a method for that dispatch slot. Therefore, the F# equivalent of a virtual method declaration and definition in another .NET language is a combination of both an abstract method declaration and a separate definition, with either the `default` keyword or the `override` keyword. For more information and examples, see [Methods](./members/methods.md). A class is considered abstract only if there are abstract methods that are declared but not defined. Therefore, classes that have abstract methods are not necessarily abstract classes. Unless a class has undefined abstract methods, do not use the **AbstractClass** attribute. diff --git a/docs/fsharp/language-reference/anonymous-records.md b/docs/fsharp/language-reference/anonymous-records.md index f82612478a908..b9187e58f710f 100644 --- a/docs/fsharp/language-reference/anonymous-records.md +++ b/docs/fsharp/language-reference/anonymous-records.md @@ -1,7 +1,7 @@ --- title: Anonymous Records -description: Learn how to use construct and use Anonymous Records, a language feature that helps with the manipulation of data. -ms.date: 06/12/2019 +description: Learn how to construct and use anonymous records, a language feature that helps with the manipulation of data. +ms.date: 11/04/2021 --- # Anonymous Records diff --git a/docs/fsharp/language-reference/async-expressions.md b/docs/fsharp/language-reference/async-expressions.md index d42e19a925660..0fb06b0119e7a 100644 --- a/docs/fsharp/language-reference/async-expressions.md +++ b/docs/fsharp/language-reference/async-expressions.md @@ -50,7 +50,7 @@ F# async expressions don't support asynchronous `try .. finally ..`. You can use Within async expressions, `use` bindings can bind to values of type . For the latter, the disposal cleanup operation is executed asynchronously. -In addition to `let!`, you can use `use!` to perform asynchronous bindings. The difference between `let!` and `use!` is the same as the difference between `let` and `use`. For `use!`, the object is disposed of at the close of the current scope. Note that in the current release of the F# language, `use!` does not allow a value to be initialized to null, even though `use` does. +In addition to `let!`, you can use `use!` to perform asynchronous bindings. The difference between `let!` and `use!` is the same as the difference between `let` and `use`. For `use!`, the object is disposed of at the close of the current scope. Note that in the current release of F#, `use!` does not allow a value to be initialized to null, even though `use` does. ## Asynchronous Primitives diff --git a/docs/fsharp/language-reference/basic-types.md b/docs/fsharp/language-reference/basic-types.md index 61cd9358298ca..cd31c43ab427e 100644 --- a/docs/fsharp/language-reference/basic-types.md +++ b/docs/fsharp/language-reference/basic-types.md @@ -1,11 +1,11 @@ --- title: Basic Types -description: Discover the fundamental basic types that are used in the F# language. +description: Discover the fundamental basic types that are used in F#. ms.date: 08/15/2020 --- # Basic types -This topic lists the basic types that are defined in the F# language. These types are the most fundamental in F#, forming the basis of nearly every F# program. They are a superset of .NET primitive types. +This topic lists the basic types that are defined in F#. These types are the most fundamental in F#, forming the basis of nearly every F# program. They are a superset of .NET primitive types. |Type|.NET type|Description|Example| |----|---------|-----------|-------| diff --git a/docs/fsharp/language-reference/byrefs.md b/docs/fsharp/language-reference/byrefs.md index f97ae17edee0d..a5035f194350c 100644 --- a/docs/fsharp/language-reference/byrefs.md +++ b/docs/fsharp/language-reference/byrefs.md @@ -8,7 +8,7 @@ ms.date: 11/04/2019 F# has two major feature areas that deal in the space of low-level programming: * The `byref`/`inref`/`outref` types, which are managed pointers. They have restrictions on usage so that you cannot compile a program that is invalid at run time. -* A `byref`-like struct, which is a [structure](structures.md) that has similar semantics and the same compile-time restrictions as `byref<'T>`. One example is . +* A `byref`-like struct, which is a [struct](structs.md) that has similar semantics and the same compile-time restrictions as `byref<'T>`. One example is . ## Syntax diff --git a/docs/fsharp/language-reference/classes.md b/docs/fsharp/language-reference/classes.md index f3e815d3a55da..0832b2b06bf4d 100644 --- a/docs/fsharp/language-reference/classes.md +++ b/docs/fsharp/language-reference/classes.md @@ -125,7 +125,7 @@ If you are not interoperating closely with object-oriented code, or if you are w Records have the advantage of being simpler than classes, but records are not appropriate when the demands of a type exceed what can be accomplished with their simplicity. Records are basically simple aggregates of values, without separate constructors that can perform custom actions, without hidden fields, and without inheritance or interface implementations. Although members such as properties and methods can be added to records to make their behavior more complex, the fields stored in a record are still a simple aggregate of values. For more information about records, see [Records](records.md). -Structures are also useful for small aggregates of data, but they differ from classes and records in that they are .NET value types. Classes and records are .NET reference types. The semantics of value types and reference types are different in that value types are passed by value. This means that they are copied bit for bit when they are passed as a parameter or returned from a function. They are also stored on the stack or, if they are used as a field, embedded inside the parent object instead of stored in their own separate location on the heap. Therefore, structures are appropriate for frequently accessed data when the overhead of accessing the heap is a problem. For more information about structures, see [Structures](structures.md). +Structures are also useful for small aggregates of data, but they differ from classes and records in that they are .NET value types. Classes and records are .NET reference types. The semantics of value types and reference types are different in that value types are passed by value. This means that they are copied bit for bit when they are passed as a parameter or returned from a function. They are also stored on the stack or, if they are used as a field, embedded inside the parent object instead of stored in their own separate location on the heap. Therefore, structures are appropriate for frequently accessed data when the overhead of accessing the heap is a problem. For more information about structures, see [Structs](structs.md). ## See also diff --git a/docs/fsharp/language-reference/compiler-directives.md b/docs/fsharp/language-reference/compiler-directives.md index 2a5ccaea01e30..914367577c9d4 100644 --- a/docs/fsharp/language-reference/compiler-directives.md +++ b/docs/fsharp/language-reference/compiler-directives.md @@ -9,6 +9,8 @@ f1_keywords: This topic describes processor directives and compiler directives. +For F# Interactive (`dotnet fsi`) directives, see [Interactive Programming with F#](../tools/fsharp-interactive/index.md). + ## Preprocessor Directives A preprocessor directive is prefixed with the # symbol and appears on a line by itself. It is interpreted by the preprocessor, which runs before the compiler itself. @@ -62,18 +64,6 @@ When you use the `#line` directive, file names must be enclosed in quotation mar These tokens indicate that the F# code generated at this location is derived from some constructs at or near line `25` in `Script1`. -## Compiler Directives - -Compiler directives resemble preprocessor directives, because they are prefixed with a # sign, but instead of being interpreted by the preprocessor, they are left for the compiler to interpret and act on. - -The following table lists the compiler directive that is available in F#. - -|Directive|Description| -|---------|-----------| -|`#light` ["on"|"off"]|Enables or disables lightweight syntax, for compatibility with other versions of ML. By default, lightweight syntax is enabled. Verbose syntax is always enabled. Therefore, you can use both lightweight syntax and verbose syntax. The directive `#light` by itself is equivalent to `#light "on"`. If you specify `#light "off"`, you must use verbose syntax for all language constructs. Syntax in the documentation for F# is presented with the assumption that you are using lightweight syntax. For more information, see [Verbose Syntax](verbose-syntax.md).| - -For interpreter (fsi.exe) directives, see [Interactive Programming with F#](../tools/fsharp-interactive/index.md). - ## See also - [F# Language Reference](index.md) diff --git a/docs/fsharp/language-reference/compiler-options.md b/docs/fsharp/language-reference/compiler-options.md index 652c745d07db0..4508587f86498 100644 --- a/docs/fsharp/language-reference/compiler-options.md +++ b/docs/fsharp/language-reference/compiler-options.md @@ -1,7 +1,7 @@ --- title: Compiler Options description: Use F# compiler command-line options to control the compilation of your F# apps and libraries. -ms.date: 08/15/2020 +ms.date: 11/04/2021 --- # Compiler options @@ -58,12 +58,32 @@ The following table shows compiler options listed alphabetically. Some of the F# |--target:[exe|winexe|library|module] filename|Specifies the type and file name of the generated compiled code.
  • `exe` means a console application.
  • `winexe` means a Windows application, which differs from the console application in that it does not have standard input/output streams (stdin, stdout, and stderr) defined.
  • `library` is an assembly without an entry point.
  • `module` is a .NET Framework module (.netmodule), which can later be combined with other modules into an assembly.
    • This compiler option is equivalent to the C# compiler option of the same name. For more information, see [/target (C# Compiler Options)](../../csharp/language-reference/compiler-options/output.md#targettype).| |`--times`|Displays timing information for compilation.| |`--utf8output`|Enables printing compiler output in the UTF-8 encoding.| -|`--warn:warning-level`|Sets a warning level (0 to 5). The default level is 3. Each warning is given a level based on its severity. Level 5 gives more, but less severe, warnings than level 1.

      Level 5 warnings are: 21 (recursive use checked at runtime), 22 (`let rec` evaluated out of order), 45 (full abstraction), and 52 (defensive copy). All other warnings are level 2.

      This compiler option is equivalent to the C# compiler option of the same name. For more information, see [/warn (C# Compiler Options)](../../csharp/language-reference/compiler-options/errors-warnings.md#warninglevel).| -|`--warnon:warning-number-list`|Enable specific warnings that might be off by default or disabled by another command-line option. The 1182 (unused variables) warning is off by default.| +|`--warn:warning-level`|Sets a warning level (0 to 5). The default level is 3. Each warning is given a level based on its severity. Level 5 gives more, but less severe, warnings than level 1.

      This compiler option is equivalent to the C# compiler option of the same name. For more information, see [/warn (C# Compiler Options)](../../csharp/language-reference/compiler-options/errors-warnings.md#warninglevel).| +|`--warnon:warning-number-list`|Enable specific warnings that might be off by default or disabled by another command-line option.| |--warnaserror[+|-] [warning-number-list]|Enables or disables the option to report warnings as errors. You can provide specific warning numbers to be disabled or enabled. Options later in the command line override options earlier in the command line. For example, to specify the warnings that you don't want reported as errors, specify `--warnaserror+` `--warnaserror-:warning-number-list`.

      This compiler option is equivalent to the C# compiler option of the same name. For more information, see [/warnaserror (C# Compiler Options)](../../csharp/language-reference/compiler-options/errors-warnings.md#treatwarningsaserrors).| |`--win32manifest:manifest-filename`|Adds a Win32 manifest file to the compilation. This compiler option is equivalent to the C# compiler option of the same name. For more information, see [/win32manifest (C# Compiler Options)](../../csharp/language-reference/compiler-options/resources.md#win32manifest).| |`--win32res:resource-filename`|Adds a Win32 resource file to the compilation.

      This compiler option is equivalent to the C# compiler option of the same name. For more information, see [/win32res ((C#) Compiler Options)](../../csharp/language-reference/compiler-options/resources.md#win32resource).| +## Opt-in warnings + +The F# compiler supports several opt-in warnings: + +|Number |Summary | Level |Description| +|-------|---------------------------------|-------|-----------| +| 21 | Recursion checked at run time | 5 | Warn when a recursive use is checked for initialization-soundness at run time. | +| 22 | Bindings executed out of order | 5 | Warn when a recursive binding may be executed out-of-order because of a forward reference. | +| 52 | Implicit copies of structs | 5 | Warn when an immutable struct is copied to ensure the original is not mutated by an operation. | +| 1178 | Implicit equality/comparison | 5 | Warn when an F# type declaration is implicitly inferred to be `NoEquality` or `NoComparison` but the attribute is not present on the type. | +| 1182 | Unused variables | n/a | Warn for unused variables. | +| 3180 | Implicit heap allocations | n/a | Warn when a mutable local is implicitly allocated as a reference cell because it has been captured by a closure. | +| 3366 | Index notation | n/a | Warn when the F# 5 index notation `expr.[idx]` is used. | +| 3517 | InlineIfLambda failure | n/a | Warn when the F# optimizer fails to inline an `InlineIfLambda` value, for example if a computed function value has been provided instead of an explicit lambda. | +| 3388 | Additional implicit upcast | n/a | Warn when an additional upcast is implicitly used, added in F# 6. | +| 3389 | Implicit widening | n/a | Warn when an implicit numeric widening is used. | +| 3390 | `op_Implicit` conversion | n/a | Warn when a .NET implicit conversion is used at a method argument. | + +You can enable these warnings by using `/warnon:NNNN` or `NNNN` where `NNNN` is the relevant warning number. + ## Related articles |Title|Description| diff --git a/docs/fsharp/language-reference/enumerations.md b/docs/fsharp/language-reference/enumerations.md index e650e62416a3b..3449799ea3f27 100644 --- a/docs/fsharp/language-reference/enumerations.md +++ b/docs/fsharp/language-reference/enumerations.md @@ -1,7 +1,7 @@ --- -title: Enumerations +title: Enums description: Learn how to use F# enumerations in place of literals to make your code more readable and maintainable. -ms.date: 08/15/2020 +ms.date: 11/04/2021 --- # Enumerations diff --git a/docs/fsharp/language-reference/exception-handling/index.md b/docs/fsharp/language-reference/exception-handling/index.md index 428558115846f..5ac238a741bbc 100644 --- a/docs/fsharp/language-reference/exception-handling/index.md +++ b/docs/fsharp/language-reference/exception-handling/index.md @@ -5,7 +5,7 @@ ms.date: 05/16/2016 --- # Exception Handling -This section contains information about exception handling support in the F# language. +This section contains information about exception handling support in F#. ## Exception Handling Basics diff --git a/docs/fsharp/language-reference/exception-handling/the-try-with-expression.md b/docs/fsharp/language-reference/exception-handling/the-try-with-expression.md index a1d5c094f75e6..5213ab4708ea3 100644 --- a/docs/fsharp/language-reference/exception-handling/the-try-with-expression.md +++ b/docs/fsharp/language-reference/exception-handling/the-try-with-expression.md @@ -5,7 +5,7 @@ ms.date: 10/29/2021 --- # Exceptions: The try...with Expression -This topic describes the `try...with` expression, the expression that is used for exception handling in the F# language. +This topic describes the `try...with` expression, the expression that is used for exception handling in F#. ## Syntax diff --git a/docs/fsharp/language-reference/fsharp-types.md b/docs/fsharp/language-reference/fsharp-types.md index 4c9f0071c426c..adf387df96f67 100644 --- a/docs/fsharp/language-reference/fsharp-types.md +++ b/docs/fsharp/language-reference/fsharp-types.md @@ -60,7 +60,7 @@ The following table shows aspects of the type syntax for F# types. |[Discriminated Unions](discriminated-unions.md)|Describes the discriminated union type, a type whose values can be any one of a set of possible types.| |[Functions](./functions/index.md)|Describes function values.| |[Classes](classes.md)|Describes the class type, an object type that corresponds to a .NET reference type. Class types can contain members, properties, implemented interfaces, and a base type.| -|[Structures](structures.md)|Describes the `struct` type, an object type that corresponds to a .NET value type. The `struct` type usually represents a small aggregate of data.| +|[Structs](structs.md)|Describes the `struct` type, an object type that corresponds to a .NET value type. The `struct` type usually represents a small aggregate of data.| |[Interfaces](interfaces.md)|Describes interface types, which are types that represent a set of members that provide certain functionality but that contain no data. An interface type must be implemented by an object type to be useful.| |[Delegates](delegates.md)|Describes the delegate type, which represents a function as an object.| |[Enumerations](enumerations.md)|Describes enumeration types, whose values belong to a set of named values.| diff --git a/docs/fsharp/language-reference/functions/index.md b/docs/fsharp/language-reference/functions/index.md index 686b8b28b57fa..9e0bc15005f11 100644 --- a/docs/fsharp/language-reference/functions/index.md +++ b/docs/fsharp/language-reference/functions/index.md @@ -1,7 +1,7 @@ --- title: Functions description: Learn about functions in F# and how F# supports common functional programming constructs. -ms.date: 10/29/2021 +ms.date: 11/04/2021 --- # Functions @@ -138,21 +138,42 @@ A *lambda expression* is an unnamed function. In the previous examples, instead You define lambda expressions by using the `fun` keyword. A lambda expression resembles a function definition, except that instead of the `=` token, the `->` token is used to separate the argument list from the function body. As in a regular function definition, the argument types can be inferred or specified explicitly, and the return type of the lambda expression is inferred from the type of the last expression in the body. For more information, see [Lambda Expressions: The `fun` Keyword](lambda-expressions-the-fun-keyword.md). -## Function Composition and Pipelining +## Pipelines -Functions in F# can be composed from other functions. The composition of two functions **function1** and **function2** is another function that represents the application of **function1** followed the application of **function2**: +The pipe operator `|>` is used extensively when processing data in F#. This operator allow you to establish "pipelines" of functions in a flexible manner. Pipelining enables function calls to be chained together as successive operations: -[!code-fsharp[Main](~/samples/snippets/fsharp/lang-ref-1/snippet113.fs)] +```fsharp +let result = 100 |> function1 |> function2 +``` -The result is 202. +The result is again 202. The following sample walks through how you can use these operators to build a simple functional pipeline: + +```fsharp -Pipelining enables function calls to be chained together as successive operations. Pipelining works as follows: +/// Square the odd values of the input and add one, using F# pipe operators. +let squareAndAddOdd values = + values + |> List.filter (fun x -> x % 2 <> 0) + |> List.map (fun x -> x * x + 1) + +let numbers = [ 1; 2; 3; 4; 5 ] + +let result = squareAndAddOdd numbers +``` + +The result is `[2; 10; 26]`. The previous sample uses list processing functions, demonstrating how functions can be used to process data when building pipelines. The pipeline operator itself is defined in the F# core library as follows: ```fsharp -let result = 100 |> function1 |> function2 +let (|>) x f = f x ``` -The result is again 202. +## Function composition + +Functions in F# can be composed from other functions. The composition of two functions **function1** and **function2** is another function that represents the application of **function1** followed the application of **function2**: + +[!code-fsharp[Main](~/samples/snippets/fsharp/lang-ref-1/snippet113.fs)] + +The result is 202. The composition operators take two functions and return a function; by contrast, the pipeline operators take a function and an argument and return a value. The following code example shows the difference between the pipeline and composition operators by showing the differences in the function signatures and usage. diff --git a/docs/fsharp/language-reference/generics/statically-resolved-type-parameters.md b/docs/fsharp/language-reference/generics/statically-resolved-type-parameters.md index 6fe4afd1e3d4a..a66a896907ce2 100644 --- a/docs/fsharp/language-reference/generics/statically-resolved-type-parameters.md +++ b/docs/fsharp/language-reference/generics/statically-resolved-type-parameters.md @@ -15,7 +15,7 @@ A *statically resolved type parameter* is a type parameter that is replaced with ## Remarks -In the F# language, there are two distinct kinds of type parameters. The first kind is the standard generic type parameter. These are indicated by an apostrophe ('), as in `'T` and `'U`. They are equivalent to generic type parameters in other .NET Framework languages. The other kind is statically resolved and is indicated by a caret symbol, as in `^T` and `^U`. +In F#, there are two distinct kinds of type parameters. The first kind is the standard generic type parameter. These are indicated by an apostrophe ('), as in `'T` and `'U`. They are equivalent to generic type parameters in other .NET Framework languages. The other kind is statically resolved and is indicated by a caret symbol, as in `^T` and `^U`. Statically resolved type parameters are primarily useful in conjunction with member constraints, which are constraints that allow you to specify that a type argument must have a particular member or members in order to be used. There is no way to create this kind of constraint by using a regular generic type parameter. diff --git a/docs/fsharp/language-reference/import-declarations-the-open-keyword.md b/docs/fsharp/language-reference/import-declarations-the-open-keyword.md index a6f74fb84e59c..bba713cc6bd0e 100644 --- a/docs/fsharp/language-reference/import-declarations-the-open-keyword.md +++ b/docs/fsharp/language-reference/import-declarations-the-open-keyword.md @@ -1,7 +1,7 @@ --- -title: "Import Declarations: The open Keyword" -description: Learn about F# import declarations and how they specify a module or namespace whose elements you can reference without using a fully qualified name. -ms.date: 08/15/2020 +title: "open Declarations" +description: Learn about F# open declarations and how they specify a module, namespace, or type whose elements you can reference without using a fully qualified name. +ms.date: 11/04/2021 --- # Import declarations: The `open` keyword diff --git a/docs/fsharp/language-reference/index.md b/docs/fsharp/language-reference/index.md index a6ad955faca51..cbb55f982f590 100644 --- a/docs/fsharp/language-reference/index.md +++ b/docs/fsharp/language-reference/index.md @@ -1,106 +1,187 @@ --- -title: Language Reference -description: Find F# language feature information from this reference to language tokens, concepts, types, expressions, and compiler-supported construct topics. -ms.date: 10/29/2021 +title: Language Guide +description: A reference guide to F# language features and tools. +ms.date: 11/04/2021 --- # F# Language Reference -This section is a reference for the F# language, a multi-paradigm programming language targeting .NET. The F# language supports functional, object-oriented, and imperative programming models. +This section is a reference for F#, a multi-paradigm programming language targeting .NET. F# supports functional, object-oriented, and imperative programming models. ## F# Core Library API reference [F# Core Library (FSharp.Core) API reference](https://fsharp.github.io/fsharp-core-docs/) is the reference for all F# Core Library namespaces, modules, types, and functions. -## F# Tokens +## Organizing F# Code -The following table shows reference articles that provide tables of keywords, symbols, and literals that are used as tokens in F#. +The following table shows reference articles related to organizing your F# code. |Title|Description| |-----|-----------| -|[Keyword Reference](keyword-reference.md)|Contains links to information about all F# language keywords.| -|[Symbol and Operator Reference](./symbol-and-operator-reference/index.md)|Contains a table of symbols and operators that are used in the F# language.| -|[Literals](literals.md)|Describes the syntax for literal values in F# and how to specify type information for F# literals.| +|[Namespaces](namespaces.md)|Learn about namespace support in F#. A namespace lets you organize code into areas of related functionality by enabling you to attach a name to a grouping of program elements.| +|[Modules](modules.md)|Learn about modules. An F# module is like a namespace and can also include values and functions. Grouping code in modules helps keep related code together and helps avoid name conflicts in your program.| +|[`open` Declarations](import-declarations-the-open-keyword.md)|Learn about how `open` works. An `open` declaration specifies a module, namespace, or type whose elements you can reference without using a fully qualified name.| +|[Signatures](signature-files.md)|Learn about signatures and signature files. A signature file contains information about the public signatures of a set of F# program elements, such as types, namespaces, and modules. It can be used to specify the accessibility of these program elements.| +|[Access Control](access-control.md)|Learn about access control in F#. Access control means declaring what clients are able to use certain program elements, such as types, methods, functions, and so on.| +|[XML Documentation](xml-documentation.md)|Learn about support for generating documentation files for XML doc comments, also known as triple slash comments. You can produce documentation from code comments in F# as in other .NET languages.| -## F# Language Concepts +## Literals and Strings -The following table shows reference topics available that describe language concepts. +The following table shows reference articles that describe literals and strings in F#. |Title|Description| |-----|-----------| -|[Functions](./functions/index.md)|Functions are the fundamental unit of program execution in any programming language. As in other languages, an F# function has a name, can have parameters and take arguments, and has a body. F# also supports functional programming constructs such as treating functions as values, using unnamed functions in expressions, composition of functions to form new functions, curried functions, and the implicit definition of functions by way of the partial application of function arguments.| -|[F# Types](fsharp-types.md)|Describes the types that are used in F# and how F# types are named and described.| -|[Type Inference](type-inference.md)|Describes how the F# compiler infers the types of values, variables, parameters, and return values.| -|[Automatic Generalization](./generics/automatic-generalization.md)|Describes generic constructs in F#.| -|[Inheritance](inheritance.md)|Describes inheritance, which is used to model the "is-a" relationship, or subtyping, in object-oriented programming.| -|[Members](./members/index.md)|Describes members of F# object types.| -|[Parameters and Arguments](parameters-and-arguments.md)|Describes language support for defining parameters and passing arguments to functions, methods, and properties. It includes information about how to pass by reference.| -|[Operator Overloading](operator-overloading.md)|Describes how to overload arithmetic operators in a class or record type, and at the global level.| -|[Casting and Conversions](casting-and-conversions.md)|Describes support for type conversions in F#.| -|[Access Control](access-control.md)|Describes access control in F#. Access control means declaring what clients are able to use certain program elements, such as types, methods, functions, and so on.| -|[Pattern Matching](pattern-matching.md)|Describes patterns, which are rules for transforming input data and are used throughout the F# language. You can compare data with a pattern, decompose data into constituent parts, or extract information from data in various ways.| -|[Active Patterns](active-patterns.md)|Describes active patterns. Active patterns enable you to define named partitions that subdivide input data. You can use active patterns to decompose data in a customized manner for each partition.| -|[Assertions](assertions.md)|Describes the `assert` expression, which is a debugging feature that you can use to test an expression. Upon failure in Debug mode, an assertion generates a system error dialog box.| -|[Exception Handling](./exception-handling/index.md)|Contains information about exception handling support in the F# language.| -|[attributes](attributes.md)|Describes attributes, which enable metadata to be applied to a programming construct.| -|[Resource Management: The `use` Keyword](resource-management-the-use-keyword.md)|Describes the keywords `use` and `using`, which can control the initialization and release of resources| -|[namespaces](namespaces.md)|Describes namespace support in F#. A namespace lets you organize code into areas of related functionality by enabling you to attach a name to a grouping of program elements.| -|[Modules](modules.md)|Describes modules. An F# module is a grouping of F# code, such as values, types, and function values, in an F# program. Grouping code in modules helps keep related code together and helps avoid name conflicts in your program.| -|[Import Declarations: The `open` Keyword](import-declarations-the-open-keyword.md)|Describes how `open` works. An import declaration specifies a module or namespace whose elements you can reference without using a fully qualified name.| -|[Signatures](signature-files.md)|Describes signatures and signature files. A signature file contains information about the public signatures of a set of F# program elements, such as types, namespaces, and modules. It can be used to specify the accessibility of these program elements.| -|[XML Documentation](xml-documentation.md)|Describes support for generating documentation files for XML doc comments, also known as triple slash comments. You can produce documentation from code comments in F# as in other .NET languages.| -|[Verbose Syntax](verbose-syntax.md)|Describes the syntax for F# constructs when lightweight syntax is not enabled. Verbose syntax is indicated by the `#light "off"` directive at the top of the code file.| -|[Plain Text Formatting](plaintext-formatting.md)|Learn how to use sprintf and other plain text formatting in F# applications and scripts.| +|[Literals](literals.md)|Learn about the syntax for literal values in F# and how to specify type information for F# literals.| +|[Strings](strings.md)|Learn about strings in F#. The `string` type represents immutable text, as a sequence of Unicode characters. `string` is an alias for `System.String` in .NET.| +|[Interpolated strings](interpolated-strings.md)|Learn about interpolated strings, a special form of string that allows you to embed F# expressions directly inside them.| + +## Values and Functions + +The following table shows reference articles that describe language concepts related to values, `let`-bindings, and functions. + +|Title|Description| +|-----|-----------| +|[Values](./values/index.md)|Learn about values, which are immutable quantities that have a specific type; values can be integral or floating point numbers, characters or text, lists, sequences, arrays, tuples, discriminated unions, records, class types, or function values.| +|[Functions](./functions/index.md)|Functions are the fundamental unit of program execution in any programming language. An F# function has a name, can have parameters and take arguments, and has a body. F# also supports functional programming constructs such as treating functions as values, using unnamed functions in expressions, composition of functions to form new functions, curried functions, and the implicit definition of functions by way of the partial application of function arguments.| +|[Function Expressions](./functions/lambda-expressions-the-fun-keyword.md)|Learn how to use the F# 'fun' keyword to define a lambda expression, which is an anonymous function.| + +## Loops and Conditionals + +The following table lists articles that describe F# loops and conditionals. + +|Title|Description| +|-----|-----------| +|[Conditional Expressions: `if...then...else`](conditional-expressions-if-then-else.md)|Learn about the `if...then...else` expression, which runs different branches of code and also evaluates to a different value depending on the Boolean expression given.| +|[Loops: `for...in` Expression](loops-for-in-expression.md)|Learn about the `for...in` expression, a looping construct that is used to iterate over the matches of a pattern in an enumerable collection such as a range expression, sequence, list, array, or other construct that supports enumeration.| +|[Loops: `for...to` Expression](loops-for-to-expression.md)|Learn about the `for...to` expression, which is used to iterate in a loop over a range of values of a loop variable.| +|[Loops: `while...do` Expression](loops-while-do-expression.md)|Learn about the `while...do` expression, which is used to perform iterative execution (looping) while a specified test condition is true.| + +## Pattern Matching + +The following table shows reference articles that describe language concepts. + +|Title|Description| +|-----|-----------| +|[Pattern Matching](pattern-matching.md)|Learn about patterns, which are rules for transforming input data and are used throughout F#. You can compare data with a pattern, decompose data into constituent parts, or extract information from data in various ways.| +|[Match Expressions](match-expressions.md)|Learn about the `match` expression, which provides branching control that is based on the comparison of an expression with a set of patterns.| +|[Active Patterns](active-patterns.md)|Learn about active patterns. Active patterns enable you to define named partitions that subdivide input data. You can use active patterns to decompose data in a customized manner for each partition.| + +## Exception Handling + +The following table shows reference articles that describe language concepts related to exception handling. + +|Title|Description| +|-----|-----------| +|[Exception Handling](./exception-handling/index.md)|Contains information about exception handling support in F#.| +|[The `try...with` Expression](exception-handling/the-try-with-expression.md)|Learn about how to use the `try...with` expression for exception handling.| +|[The `try...finally` Expression](exception-handling/the-try-finally-expression.md)|Learn about how the F# `try...finally` expression enables you to execute clean-up code even if a block of code throws an exception.| +|[The `use` Keyword](resource-management-the-use-keyword.md)|Learn about the keywords `use` and `using`, which can control the initialization and release of resources.| +|[Assertions](assertions.md)|Learn about the `assert` expression, which is a debugging feature that you can use to test an expression. Upon failure in Debug mode, an assertion generates a system error dialog box.| + +## Types and Type Inference + +The following table shows reference articles that describe how types and type inference work in F#. + +|Title|Description| +|-----|-----------| +|[Types](fsharp-types.md)|Learn about the types that are used in F# and how F# types are named and described.| +|[Basic Types](basic-types.md)|Learn about the fundamental types that are used in F#. It also provides the corresponding .NET types and the minimum and maximum values for each type.| +|[Unit Type](unit-type.md)|Learn about the `unit` type, which is a type that indicates the absence of a specific value; the `unit` type has only a single value, which acts as a placeholder when no other value exists or is needed.| +|[Type Abbreviations](type-abbreviations.md)|Learn about type abbreviations, which are alternate names for types.| +|[Type Inference](type-inference.md)|Learn about how the F# compiler infers the types of values, variables, parameters, and return values.| +|[Casting and Conversions](casting-and-conversions.md)|Learn about support for type conversions in F#.| +|[Generics](./generics/index.md)|Learn about generic constructs in F#.| +|[Automatic Generalization](./generics/automatic-generalization.md)|Learn about how F# automatically generalizes the arguments and types of functions so that they work with multiple types when possible.| +|[Constraints](casting-and-conversions.md)|Learn about constraints that apply to generic type parameters to specify the requirements for a type argument in a generic type or function.| +|[Flexible Types](flexible-types.md)|Learn about flexible types. A flexible type annotation is an indication that a parameter, variable, or value has a type that is compatible with type specified, where compatibility is determined by position in an object-oriented hierarchy of classes or interfaces.| +|[Units of Measure](units-of-measure.md)|Learn about units of measure. Floating point values in F# can have associated units of measure, which are typically used to indicate length, volume, mass, and so on.| +|[Byrefs](byrefs.md)|Learn about byref and byref-like types in F#, which are used for low-level programming.| + +## Tuples, Lists, Collections, Options + +The following table shows reference articles that describe types supported by F#. + +|Title|Description| +|-----|-----------| +|[Tuples](tuples.md)|Learn about tuples, which are groupings of unnamed but ordered values of possibly different types.| +|[Collections](fsharp-collection-types.md)|An overview of the F# functional collection types, including types for arrays, lists, sequences (seq), maps, and sets.| +|[Lists](lists.md)|Learn about lists. A list in F# is an ordered, immutable series of elements all of the same type.| +|[Options](options.md)|Learn about the option type. An option in F# is used when a value may or may not exist. An option has an underlying type and may either hold a value of that type or it may not have a value.| +|[Arrays](arrays.md)|Learn about arrays. Arrays are fixed-size, zero-based, mutable sequences of consecutive data elements, all of the same type.| +|[Sequences](sequences.md)|Learn about sequences. A sequence is a logical series of elements all of one type. Individual sequence elements are only computed if necessary, so the representation may be smaller than a literal element count indicates.| +|[Reference Cells](reference-cells.md)|Learn about reference cells, which are storage locations that enable you to create mutable variables with reference semantics.| + +## Records and Discriminated Unions + +The following table shows reference articles that describe record and discriminated union type definitions supported by F#. + +|Title|Description| +|-----|-----------| +|[Records](records.md)|Learn about records. Records represent simple aggregates of named values, optionally with members.| +|[Anonymous Records](anonymous-records.md)|Learn how to construct and use anonymous records, a language feature that helps with the manipulation of data.| +|[Discriminated Unions](discriminated-unions.md)|Learn about discriminated unions, which provide support for values that may be one of a variety of named cases, each with possibly different values and types.| +|[Structs](structs.md)|Learn about structs, which are compact object types that can be more efficient than a class for types that have a small amount of data and simple behavior.| +|[Enumerations](enumerations.md)|Enumerations are types that have a defined set of named values. You can use them in place of literals to make code more readable and maintainable.| -## F# Types +## Object Programming -The following table shows reference topics available that describe types supported by the F# language. +The following table shows reference articles that describe F# object programming. |Title|Description| |-----|-----------| -|[values](./values/index.md)|Describes values, which are immutable quantities that have a specific type; values can be integral or floating point numbers, characters or text, lists, sequences, arrays, tuples, discriminated unions, records, class types, or function values.| -|[Basic Types](basic-types.md)|Describes the fundamental basic types that are used in the F# language. It also provides the corresponding .NET types and the minimum and maximum values for each type.| -|[Unit Type](unit-type.md)|Describes the `unit` type, which is a type that indicates the absence of a specific value; the `unit` type has only a single value, which acts as a placeholder when no other value exists or is needed.| -|[Strings](strings.md)|Describes strings in F#. The `string` type represents immutable text, as a sequence of Unicode characters. `string` is an alias for `System.String` in the .NET Framework.| -|[Tuples](tuples.md)|Describes tuples, which are groupings of unnamed but ordered values of possibly different types.| -|[F# Collection Types](fsharp-collection-types.md)|An overview of the F# functional collection types, including types for arrays, lists, sequences (seq), maps, and sets.| -|[Lists](lists.md)|Describes lists. A list in F# is an ordered, immutable series of elements all of the same type.| -|[Options](options.md)|Describes the option type. An option in F# is used when a value may or may not exist. An option has an underlying type and may either hold a value of that type or it may not have a value.| -|[Sequences](sequences.md)|Describes sequences. A sequence is a logical series of elements all of one type. Individual sequence elements are only computed if necessary, so the representation may be smaller than a literal element count indicates.| -|[Arrays](arrays.md)|Describes arrays. Arrays are fixed-size, zero-based, mutable sequences of consecutive data elements, all of the same type.| -|[Records](records.md)|Describes records. Records represent simple aggregates of named values, optionally with members.| -|[Discriminated Unions](discriminated-unions.md)|Describes discriminated unions, which provide support for values that may be one of a variety of named cases, each with possibly different values and types.| -|[Enumerations](enumerations.md)|Describes enumerations are types that have a defined set of named values. You can use them in place of literals to make code more readable and maintainable.| -|[Reference Cells](reference-cells.md)|Describes reference cells, which are storage locations that enable you to create mutable variables with reference semantics.| -|[Type Abbreviations](type-abbreviations.md)|Describes type abbreviations, which are alternate names for types.| -|[Classes](classes.md)|Describes classes, which are types that represent objects that can have properties, methods, and events.| -|[Structures](structures.md)|Describes structures, which are compact object types that can be more efficient than a class for types that have a small amount of data and simple behavior.| -|[Interfaces](interfaces.md)|Describes interfaces, which specify sets of related members that other classes implement.| -|[Abstract Classes](abstract-classes.md)|Describes abstract classes, which are classes that leave some or all members unimplemented, so that implementations can be provided by derived classes.| -|[Type Extensions](type-extensions.md)|Describes type extensions, which let you add new members to a previously defined object type.| -|[Flexible Types](flexible-types.md)|Describes flexible types. A flexible type annotation is an indication that a parameter, variable, or value has a type that is compatible with type specified, where compatibility is determined by position in an object-oriented hierarchy of classes or interfaces.| -|[Delegates](delegates.md)|Describes delegates, which represent a function call as an object.| -|[Units of Measure](units-of-measure.md)|Describes units of measure. Floating point values in F# can have associated units of measure, which are typically used to indicate length, volume, mass, and so on.| -|[Type Providers](../tutorials/type-providers/index.md)|Describes type provides and provides links to walkthroughs on using the built-in type providers to access databases and web services.| - -## F# Expressions +|[Classes](classes.md)|Learn about classes, which are types that represent objects that can have properties, methods, and events.| +|[Interfaces](interfaces.md)|Learn about interfaces, which specify sets of related members that other classes implement.| +|[Abstract Classes](abstract-classes.md)|Learn about abstract classes, which are classes that leave some or all members unimplemented, so that implementations can be provided by derived classes.| +|[Type Extensions](type-extensions.md)|Learn about type extensions, which let you add new members to a previously defined object type.| +|[Delegates](delegates.md)|Learn about delegates, which represent a function call as an object.| +|[Inheritance](inheritance.md)|Learn about inheritance, which is used to model the "is-a" relationship, or subtyping, in object-oriented programming.| +|[Members](./members/index.md)|Learn about members of F# object types.| +|[Parameters and Arguments](parameters-and-arguments.md)|Learn about language support for defining parameters and passing arguments to functions, methods, and properties. It includes information about how to pass by reference.| +|[Operator Overloading](operator-overloading.md)|Learn about how to overload arithmetic operators in a class or record type, and at the global level.| +|[Object Expressions](object-expressions.md)|Learn about object expressions, which are expressions that create new instances of a dynamically created, anonymous object type that is based on an existing base type, interface, or set of interfaces.| + +## Expressions for Lazy, Async, Tasks, Queries and other computations The following table lists topics that describe F# expressions. |Title|Description| |-----|-----------| -|[Conditional Expressions: `if...then...else`](conditional-expressions-if-then-else.md)|Describes the `if...then...else` expression, which runs different branches of code and also evaluates to a different value depending on the Boolean expression given.| -|[Match Expressions](match-expressions.md)|Describes the `match` expression, which provides branching control that is based on the comparison of an expression with a set of patterns.| -|[Loops: `for...to` Expression](loops-for-to-expression.md)|Describes the `for...to` expression, which is used to iterate in a loop over a range of values of a loop variable.| -|[Loops: `for...in` Expression](loops-for-in-expression.md)|Describes the `for...in` expression, a looping construct that is used to iterate over the matches of a pattern in an enumerable collection such as a range expression, sequence, list, array, or other construct that supports enumeration.| -|[Loops: `while...do` Expression](loops-while-do-expression.md)|Describes the `while...do` expression, which is used to perform iterative execution (looping) while a specified test condition is true.| -|[Object Expressions](object-expressions.md)|Describes object expressions, which are expressions that create new instances of a dynamically created, anonymous object type that is based on an existing base type, interface, or set of interfaces.| -|[Lazy Expressions](lazy-expressions.md)|Describes lazy expressions, which are computations that are not evaluated immediately, but are instead evaluated when the result is actually needed.| -|[Computation Expressions](computation-expressions.md)|Describes computation expressions in F#, which provide a convenient syntax for writing computations that can be sequenced and combined using control flow constructs and bindings. They can be used to manage data, control, and side effects in functional programs.| -|[Sequence Expressions](sequences.md)|Describes sequence expressions, which let you generate sequences of data on-demand.| -|[Async Expressions](async-expressions.md)|Describes async expressions, which let you write asynchronous code in a way that is very close to the way you would naturally write synchronous code.| -|[Task Expressions](task-expressions.md)|Describes task expressions, which are an alternative way of writing asynchronous code used when interoperating with .NET code that consumes or produces .NET tasks.| -|[Code Quotations](code-quotations.md)|Describes code quotations, a language feature that enables you to generate and work with F# code expressions programmatically.| -|[Query Expressions](query-expressions.md)|Describes query expressions, a language feature that implements LINQ for F# and enables you to write queries against a data source or enumerable collection.| +|[Lazy Expressions](lazy-expressions.md)|Learn about lazy expressions, which are computations that are not evaluated immediately, but are instead evaluated when the result is actually needed.| +|[Computation Expressions](computation-expressions.md)|Learn about computation expressions in F#, which provide a convenient syntax for writing computations that can be sequenced and combined using control flow constructs and bindings. They can be used to manage data, control, and side effects in functional programs.| +|[Sequence Expressions](sequences.md)|Learn about sequence expressions, which let you generate sequences of data on-demand.| +|[Async Expressions](async-expressions.md)|Learn about async expressions, which let you write asynchronous code in a way that is very close to the way you would naturally write synchronous code.| +|[Task Expressions](task-expressions.md)|Learn about task expressions, which are an alternative way of writing asynchronous code used when interoperating with .NET code that consumes or produces .NET tasks.| +|[Query Expressions](query-expressions.md)|Learn about query expressions, a language feature that implements LINQ for F# and enables you to write queries against a data source or enumerable collection.| + +## Attributes, Reflection, Quotations and Plain Text Formatting + +The following table lists articles that describe F# reflective features, including attributes, quotations, `nameof`, and plain text formatting. + +|Title|Description| +|-----|-----------| +|[Attributes](attributes.md)|Learn how F# Attributes enable metadata to be applied to a programming construct.| +|[nameof](nameof.md)|Learn about the `nameof` operator, a metaprogramming feature that allows you to produce the name of any symbol in your source code.| +|[Caller Information](caller-information.md)|Learn about how to use Caller Info Argument Attributes to obtain caller information from a method.| +|[Source Line, File, and Path Identifiers](source-line-file-path-identifiers.md)|Learn about the identifiers `__LINE__`, `__SOURCE_DIRECTORY__`, and `__SOURCE_FILE__`, which are built-in values that enable you to access the source line number, directory, and file name in your code.| +|[Code Quotations](code-quotations.md)|Learn about code quotations, a language feature that enables you to generate and work with F# code expressions programmatically.| +|[Plain Text Formatting](plaintext-formatting.md)|Learn how to use sprintf and other plain text formatting in F# applications and scripts.| + +## Type Providers + +The following table lists articles that describe F# type providers. + +|Title|Description| +|-----|-----------| +|[Type Providers](../tutorials/type-providers/index.md)|Learn about type providers and find links to walkthroughs on using the built-in type providers to access databases and web services.| +|[Create a Type Provider](../tutorials/type-providers/creating-a-type-provider.md)|Learn how to create your own F# type providers by examining several simple type providers that illustrate the basic concepts.| + +## Reference Tables + +The following table shows reference articles that provide tables of keywords, symbols, and literals that are used as tokens in F#. + +|Title|Description| +|-----|-----------| +|[Keyword Reference](keyword-reference.md)|Contains links to information about all F# language keywords.| +|[Symbol and Operator Reference](./symbol-and-operator-reference/index.md)|Contains a table of symbols and operators that are used in F#.| ## Compiler-supported Constructs @@ -109,5 +190,4 @@ The following table lists topics that describe special compiler-supported constr |Topic|Description| |-----|-----------| |[Compiler Options](compiler-options.md)|Describes the command-line options for the F# compiler.| -|[Compiler Directives](compiler-directives.md)|Describes processor directives and compiler directives.| -|[Source Line, File, and Path Identifiers](source-line-file-path-identifiers.md)|Describes the identifiers `__LINE__`, `__SOURCE_DIRECTORY__`, and `__SOURCE_FILE__`, which are built-in values that enable you to access the source line number, directory and file name in your code.| +|[Compiler Directives](compiler-directives.md)|Describes the processor directives and compiler directives supported by the F# compiler.| diff --git a/docs/fsharp/language-reference/keyword-reference.md b/docs/fsharp/language-reference/keyword-reference.md index 95020aba3e513..321afc27275a9 100644 --- a/docs/fsharp/language-reference/keyword-reference.md +++ b/docs/fsharp/language-reference/keyword-reference.md @@ -1,6 +1,6 @@ --- title: Keyword Reference -description: Find links to information about all of the F# language keywords. +description: Find links to information about all of F# keywords. f1_keywords: - new_FS - use_FS @@ -104,7 +104,7 @@ The following table shows all F# keywords in alphabetical order, together with b |`downto`|[Loops: `for...to` Expression](loops-for-to-expression.md)|In a `for` expression, used when counting in reverse.| |`elif`|[Conditional Expressions: `if...then...else`](conditional-expressions-if-then-else.md)|Used in conditional branching. A short form of `else if`.| |`else`|[Conditional Expressions: `if...then...else`](conditional-expressions-if-then-else.md)|Used in conditional branching.| -|`end`|[Structures](structures.md)

      [Discriminated Unions](discriminated-unions.md)

      [Records](records.md)

      [Type Extensions](type-extensions.md)

      [Verbose Syntax](verbose-syntax.md)|In type definitions and type extensions, indicates the end of a section of member definitions.

      In verbose syntax, used to specify the end of a code block that starts with the `begin` keyword.| +|`end`|[Structs](structs.md)

      [Discriminated Unions](discriminated-unions.md)

      [Records](records.md)

      [Type Extensions](type-extensions.md)

      [Verbose Syntax](verbose-syntax.md)|In type definitions and type extensions, indicates the end of a section of member definitions.

      In verbose syntax, used to specify the end of a code block that starts with the `begin` keyword.| |`exception`|[Exception Handling](./exception-handling/index.md)

      [Exception Types](./exception-handling/exception-types.md)|Used to declare an exception type.| |`extern`|[External Functions](./functions/external-functions.md)|Indicates that a declared program element is defined in another binary or assembly.| |`false`|[Primitive Types](basic-types.md)|Used as a Boolean literal.| @@ -143,12 +143,12 @@ The following table shows all F# keywords in alphabetical order, together with b |`return!`|[Computation Expressions](computation-expressions.md)

      [Async expressions](async-expressions.md)

      [Task expressions](task-expressions.md)|Used to indicate a computation expression that, when evaluated, provides the result of the containing computation expression.| |`select`|[Query Expressions](query-expressions.md)|Used in query expressions to specify what fields or columns to extract. Note that this is a contextual keyword, which means that it is not actually a reserved word and it only acts like a keyword in appropriate context.| |`static`|[Members](./members/index.md)|Used to indicate a method or property that can be called without an instance of a type, or a value member that is shared among all instances of a type.| -|`struct`|[Structures](structures.md)

      [Tuples](tuples.md)

      [Constraints](./generics/constraints.md)|Used to declare a structure type.

      Used to specify a struct tuple.

      Also used in generic parameter constraints.

      Used for OCaml compatibility in module definitions.| +|`struct`|[Structs](structs.md)

      [Tuples](tuples.md)

      [Constraints](./generics/constraints.md)|Used to declare a structure type.

      Used to specify a struct tuple.

      Also used in generic parameter constraints.

      Used for OCaml compatibility in module definitions.| |`then`|[Conditional Expressions: `if...then...else`](conditional-expressions-if-then-else.md)

      [Constructors](./members/constructors.md)|Used in conditional expressions.

      Also used to perform side effects after object construction.| |`to`|[Loops: `for...to` Expression](loops-for-to-expression.md)|Used in `for` loops to indicate a range.| |`true`|[Primitive Types](basic-types.md)|Used as a Boolean literal.| |`try`|[Exceptions: The try...with Expression](./exception-handling/the-try-with-expression.md)

      [Exceptions: The try...finally Expression](./exception-handling/the-try-finally-expression.md)|Used to introduce a block of code that might generate an exception. Used together with `with` or `finally`.| -|`type`|[F# Types](fsharp-types.md)

      [Classes](classes.md)

      [Records](records.md)

      [Structures](structures.md)

      [Enumerations](enumerations.md)

      [Discriminated Unions](discriminated-unions.md)

      [Type Abbreviations](type-abbreviations.md)

      [Units of Measure](units-of-measure.md)|Used to declare a class, record, structure, discriminated union, enumeration type, unit of measure, or type abbreviation.| +|`type`|[F# Types](fsharp-types.md)

      [Classes](classes.md)

      [Records](records.md)

      [Structs](structs.md)

      [Enumerations](enumerations.md)

      [Discriminated Unions](discriminated-unions.md)

      [Type Abbreviations](type-abbreviations.md)

      [Units of Measure](units-of-measure.md)|Used to declare a class, record, structure, discriminated union, enumeration type, unit of measure, or type abbreviation.| |`upcast`|[Casting and Conversions](casting-and-conversions.md)|Used to convert to a type that is higher in the inheritance chain.| |`use`|[Resource Management: The `use` Keyword](resource-management-the-use-keyword.md)|Used instead of `let` for values that require `Dispose` to be called to free resources.| |`use!`|[Computation Expressions](computation-expressions.md)

      [Async expressions](async-expressions.md)

      [Task expressions](task-expressions.md)|Used instead of `let!` in async expressions and other computation expressions for values that require `Dispose` to be called to free resources.| @@ -174,7 +174,7 @@ The following tokens are reserved in F# because they are keywords in the OCaml l If you use the `--mlcompatibility` compiler option, the above keywords are available for use as identifiers. -The following tokens are reserved as keywords for future expansion of the F# language: +The following tokens are reserved as keywords for future expansion of F#: - `break` - `checked` diff --git a/docs/fsharp/language-reference/members/index.md b/docs/fsharp/language-reference/members/index.md index fdc0b1dfe5ae1..1a34bb2ec824e 100644 --- a/docs/fsharp/language-reference/members/index.md +++ b/docs/fsharp/language-reference/members/index.md @@ -9,9 +9,9 @@ This section describes members of F# object types. ## Remarks -*Members* are features that are part of a type definition and are declared with the `member` keyword. F# object types such as records, classes, discriminated unions, interfaces, and structures support members. For more information, see [Records](../records.md), [Classes](../classes.md), [Discriminated Unions](../discriminated-unions.md), [Interfaces](../interfaces.md), and [Structures](../structures.md). +*Members* are features that are part of a type definition and are declared with the `member` keyword. F# object types such as records, classes, discriminated unions, interfaces, and structures support members. For more information, see [Records](../records.md), [Classes](../classes.md), [Discriminated Unions](../discriminated-unions.md), [Interfaces](../interfaces.md), and [Structs](../structs.md). -Members typically make up the public interface for a type, which is why they are public unless otherwise specified. Members can also be declared private or internal. For more information, see [Access Control](../access-control.md). Signatures for types can also be used to expose or not expose certain members of a type. For more information, see [Signatures](../signature-files.md). +Members typically make up the public interface for a type, which is why they are public unless otherwise specified. Members can also be declared private or internal. For more information, see [Access Control](../access-control.md). Signatures files can also be used to expose or not expose certain members of a type. For more information, see [Signatures](../signature-files.md). Private fields and `do` bindings, which are used only with classes, are not true members, because they are never part of the public interface of a type and are not declared with the `member` keyword, but they are described in this section also. @@ -27,4 +27,5 @@ Private fields and `do` bindings, which are used only with classes, are not true |[Constructors](constructors.md)|Describes special functions that initialize objects of a type.| |[Operator Overloading](../operator-overloading.md)|Describes the definition of customized operators for types.| |[Events](events.md)|Describes the definition of events and event handling support in F#.| -|[Explicit Fields: The `val` Keyword](explicit-fields-the-val-keyword.md)|Describes the definition of uninitialized fields in a type.| +|[Structs](../structs.md)|Describes the definition of structs in F#.| +|[Explicit Fields](explicit-fields-the-val-keyword.md)|Describes the definition of uninitialized fields in a type.| diff --git a/docs/fsharp/language-reference/modules.md b/docs/fsharp/language-reference/modules.md index c5636abbeacec..566c9c8288e89 100644 --- a/docs/fsharp/language-reference/modules.md +++ b/docs/fsharp/language-reference/modules.md @@ -5,7 +5,7 @@ ms.date: 04/24/2017 --- # Modules -In the context of the F# language, a *module* is a grouping of F# code, such as values, types, and function values, in an F# program. Grouping code in modules helps keep related code together and helps avoid name conflicts in your program. +In the context of F#, a *module* is a grouping of F# code, such as values, types, and function values, in an F# program. Grouping code in modules helps keep related code together and helps avoid name conflicts in your program. ## Syntax diff --git a/docs/fsharp/language-reference/nullable-value-types.md b/docs/fsharp/language-reference/nullable-value-types.md index 3e7d2e57c3697..fc2516a404253 100644 --- a/docs/fsharp/language-reference/nullable-value-types.md +++ b/docs/fsharp/language-reference/nullable-value-types.md @@ -6,7 +6,7 @@ ms.date: 11/19/2020 # Nullable value types -A _nullable value type_ `Nullable<'T>` represents any [struct](structures.md) type that could also be `null`. This is helpful when interacting with libraries and components that may choose to represent these kinds of types, like integers, with a `null` value for efficiency reasons. The underlying type that backs this construct is . +A _nullable value type_ `Nullable<'T>` represents any [struct](structs.md) type that could also be `null`. This is helpful when interacting with libraries and components that may choose to represent these kinds of types, like integers, with a `null` value for efficiency reasons. The underlying type that backs this construct is . ## Syntax @@ -131,5 +131,5 @@ The `?>` comparison checks if the left-hand side is nullable and only succeeds i ## See also -- [Structures](structures.md) +- [Structs](structs.md) - [F# Options](options.md) diff --git a/docs/fsharp/language-reference/pattern-matching.md b/docs/fsharp/language-reference/pattern-matching.md index 5b202d4aa3475..5535213a35d39 100644 --- a/docs/fsharp/language-reference/pattern-matching.md +++ b/docs/fsharp/language-reference/pattern-matching.md @@ -5,7 +5,7 @@ ms.date: 11/12/2020 --- # Pattern Matching -Patterns are rules for transforming input data. They are used throughout the F# language to compare data with a logical structure or structures, decompose data into constituent parts, or extract information from data in various ways. +Patterns are rules for transforming input data. They are used throughout F# to compare data with a logical structure or structures, decompose data into constituent parts, or extract information from data in various ways. ## Remarks diff --git a/docs/fsharp/language-reference/strings.md b/docs/fsharp/language-reference/strings.md index 3b212e2a2b2c4..7e3f724a14393 100644 --- a/docs/fsharp/language-reference/strings.md +++ b/docs/fsharp/language-reference/strings.md @@ -97,4 +97,5 @@ Additional functionality for string handling is included in the `String` module ## See also +- [Interpolated Strings](interpolated-strings.md) - [F# Language Reference](index.md) diff --git a/docs/fsharp/language-reference/structures.md b/docs/fsharp/language-reference/structs.md similarity index 100% rename from docs/fsharp/language-reference/structures.md rename to docs/fsharp/language-reference/structs.md diff --git a/docs/fsharp/language-reference/symbol-and-operator-reference/arithmetic-operators.md b/docs/fsharp/language-reference/symbol-and-operator-reference/arithmetic-operators.md index 41e9b6fa78057..140190fab65fd 100644 --- a/docs/fsharp/language-reference/symbol-and-operator-reference/arithmetic-operators.md +++ b/docs/fsharp/language-reference/symbol-and-operator-reference/arithmetic-operators.md @@ -5,7 +5,7 @@ ms.date: 04/04/2018 --- # Arithmetic Operators -This topic describes arithmetic operators that are available in the F# language. +This topic describes arithmetic operators that are available in F#. ## Summary of Binary Arithmetic Operators diff --git a/docs/fsharp/language-reference/symbol-and-operator-reference/bitwise-operators.md b/docs/fsharp/language-reference/symbol-and-operator-reference/bitwise-operators.md index efc7fb7829774..917ffde9d8501 100644 --- a/docs/fsharp/language-reference/symbol-and-operator-reference/bitwise-operators.md +++ b/docs/fsharp/language-reference/symbol-and-operator-reference/bitwise-operators.md @@ -5,11 +5,11 @@ ms.date: 07/20/2018 --- # Bitwise Operators -This topic describes bitwise operators that are available in the F# language. +This topic describes bitwise operators that are available in F#. ## Summary of Bitwise Operators -The following table describes the bitwise operators that are supported for unboxed integral types in the F# language. +The following table describes the bitwise operators that are supported for unboxed integral types in F#. |Operator|Notes| |--------|-----| diff --git a/docs/fsharp/language-reference/symbol-and-operator-reference/boolean-operators.md b/docs/fsharp/language-reference/symbol-and-operator-reference/boolean-operators.md index 2f925b260be72..babf7ef877bef 100644 --- a/docs/fsharp/language-reference/symbol-and-operator-reference/boolean-operators.md +++ b/docs/fsharp/language-reference/symbol-and-operator-reference/boolean-operators.md @@ -5,11 +5,11 @@ ms.date: 05/16/2016 --- # Boolean Operators -This topic describes the support for Boolean operators in the F# language. +This topic describes the support for Boolean operators in F#. ## Summary of Boolean Operators -The following table summarizes the Boolean operators that are available in the F# language. The only type supported by these operators is the `bool` type. +The following table summarizes the Boolean operators that are available in F#. The only type supported by these operators is the `bool` type. |Operator|Description| |--------|-----------| diff --git a/docs/fsharp/language-reference/symbol-and-operator-reference/index.md b/docs/fsharp/language-reference/symbol-and-operator-reference/index.md index 5cc908e34eaad..abc7fb1652a6a 100644 --- a/docs/fsharp/language-reference/symbol-and-operator-reference/index.md +++ b/docs/fsharp/language-reference/symbol-and-operator-reference/index.md @@ -1,13 +1,13 @@ --- title: Symbol and Operator Reference description: Learn about the symbols and operators that are used in the F# programming language. -ms.date: 07/26/2021 +ms.date: 11/04/2021 fl_keywords: - "|>_FS" --- # Symbol and operator reference -This article includes tables describing the symbols and operators that are used in the F# language and provides a brief description of each. Some symbols +This article includes tables describing the symbols and operators that are used in F# and provides a brief description of each. Some symbols and operators have two or more entries when used in multiple roles. ## Comment, compiler directive and attribute symbols @@ -19,7 +19,7 @@ The following table describes symbols related to comments, compiler directives a |`(*...*)`||Delimits a comment that could span multiple lines.| |`//`||Indicates the beginning of a single-line comment.| |`///`|[XML Documentation](../xml-documentation.md)|Indicates an XML comment.| -|`#`|[Compiler Directives](../compiler-directives.md)|Prefixes a preprocessor or compiler directive, such as `#light`.| +|`#`|[Compiler Directives](../compiler-directives.md)|Prefixes a preprocessor or compiler directive.| |`[<...>]`|[Attributes](../attributes.md)|Delimits an attribute.| ## String and identifier symbols @@ -91,7 +91,7 @@ The following table describes the operators and symbols related to functions. |Symbol or operator|Links|Description| |------------------|-----|-----------| |`->`|[Functions](../functions/index.md)|In function expressions, separates the input pattern from the output expression.| -||>|[Functions](../functions/index.md)|Passes the result of the left side to the function on the right side (forward pipe operator).| +||>|[Functions](../functions/index.md#pipelines)|Passes the result of the left side to the function on the right side (forward pipe operator).| |||>|[( ||> )<'T1,'T2,'U> Function](https://fsharp.github.io/fsharp-core-docs/reference/fsharp-core-operators.html#(%20%7C%7C%3E%20))|Passes the tuple of two arguments on the left side to the function on the right side.| ||||>|[( |||> )<'T1,'T2,'T3,'U> Function](https://fsharp.github.io/fsharp-core-docs/reference/fsharp-core-operators.html#(%20%7C%7C%7C%3E%20))|Passes the tuple of three arguments on the left side to the function on the right side.| |`>>`|[Functions](../functions/index.md)|Composes two functions (forward composition operator).| @@ -232,7 +232,7 @@ The following table describes symbols related to [Reference Cells](../reference- ## Operator precedence -The following table shows the order of precedence of operators and other expression keywords in the F# language, in order from lowest precedence to the highest precedence. Also listed is the associativity, if applicable. +The following table shows the order of precedence of operators and other expression keywords in F#, in order from lowest precedence to the highest precedence. Also listed is the associativity, if applicable. |Operator|Associativity| |--------|-------------| diff --git a/docs/fsharp/language-reference/symbol-and-operator-reference/nullable-operators.md b/docs/fsharp/language-reference/symbol-and-operator-reference/nullable-operators.md index a73d56713c02f..50b58700cee5d 100644 --- a/docs/fsharp/language-reference/symbol-and-operator-reference/nullable-operators.md +++ b/docs/fsharp/language-reference/symbol-and-operator-reference/nullable-operators.md @@ -13,7 +13,7 @@ Nullable operators are binary arithmetic or comparison operators that work with ## Table of Nullable Operators -The following table lists nullable operators supported in the F# language. +The following table lists nullable operators supported in F#. |Nullable on left|Nullable on right|Both sides nullable| |---|---|---| diff --git a/docs/fsharp/language-reference/values/null-values.md b/docs/fsharp/language-reference/values/null-values.md index 0f01f1e24cfcb..f5187e754e22e 100644 --- a/docs/fsharp/language-reference/values/null-values.md +++ b/docs/fsharp/language-reference/values/null-values.md @@ -15,7 +15,7 @@ For a type defined in F# and used strictly from F#, the only way to create a nul You can use the `option` type in F# when you might use a reference variable with a possible null value in another .NET language. Instead of null, with an F# `option` type, you use the option value `None` if there is no object. You use the option value `Some(obj)` with an object `obj` when there is an object. For more information, see [Options](../options.md). Note that you can still pack a `null` value into an Option if, for `Some x`, `x` happens to be `null`. Because of this, it is important you use `None` when a value is `null`. -The `null` keyword is a valid keyword in the F# language, and you have to use it when you are working with .NET Framework APIs or other APIs that are written in another .NET language. The two situations in which you might need a null value are when you call a .NET API and pass a null value as an argument, and when you interpret the return value or an output parameter from a .NET method call. +The `null` keyword is a valid keyword in F#, and you have to use it when you are working with .NET Framework APIs or other APIs that are written in another .NET language. The two situations in which you might need a null value are when you call a .NET API and pass a null value as an argument, and when you interpret the return value or an output parameter from a .NET method call. To pass a null value to a .NET method, just use the `null` keyword in the calling code. The following code example illustrates this. diff --git a/docs/fsharp/language-reference/verbose-syntax.md b/docs/fsharp/language-reference/verbose-syntax.md index b11e573ccef00..781bff52102b3 100644 --- a/docs/fsharp/language-reference/verbose-syntax.md +++ b/docs/fsharp/language-reference/verbose-syntax.md @@ -5,7 +5,7 @@ ms.date: 05/16/2016 --- # Verbose Syntax -There are two forms of syntax available for many constructs in the F# language: *verbose syntax* and *lightweight syntax*. The verbose syntax is not as commonly used, but has the advantage of being less sensitive to indentation. The lightweight syntax is shorter and uses indentation to signal the beginning and end of constructs, rather than additional keywords like `begin`, `end`, `in`, and so on. The default syntax is the lightweight syntax. This topic describes the syntax for F# constructs when lightweight syntax is not enabled. Verbose syntax is always enabled, so even if you enable lightweight syntax, you can still use verbose syntax for some constructs. You can disable lightweight syntax by using the `#light "off"` directive. +There are two forms of syntax available for many constructs in F#: *verbose syntax* and *lightweight syntax*. The verbose syntax is not as commonly used, but has the advantage of being less sensitive to indentation. The lightweight syntax is shorter and uses indentation to signal the beginning and end of constructs, rather than additional keywords like `begin`, `end`, `in`, and so on. The default syntax is the lightweight syntax. This topic describes the syntax for F# constructs when lightweight syntax is not enabled. Verbose syntax is always enabled, so even if you enable lightweight syntax, you can still use verbose syntax for some constructs. ## Table of Constructs diff --git a/docs/fsharp/scenarios/machine-learning.md b/docs/fsharp/scenarios/machine-learning.md new file mode 100644 index 0000000000000..c409093997dbb --- /dev/null +++ b/docs/fsharp/scenarios/machine-learning.md @@ -0,0 +1,28 @@ +--- +title: F# Machine Learning Tools +description: Learn about machine learning with F#. +ms.date: 11/03/2021 +--- +# Machine Learning with F\# + +F# excels at data science and machine learning. This article gives links to some significant resources related to this mode of use of F#. + +For information about other options that are available for machine learning and data science, see the F# Software Foundation's [Guide to Data Science with F#](https://fsharp.org/guides/data-science/). + +## ML.NET + +[ML.NET](https://dotnet.microsoft.com/apps/machinelearning-ai/ml-dotnet) is an open source and cross-platform machine learning framework built for .NET developers. With ML.NET, you can create custom ML models using C# or F# without having to leave the .NET ecosystem. ML.NET lets you reuse all the knowledge, skills, code, and libraries you already have as a .NET developer so that you can easily integrate machine learning into your web, mobile, desktop, games, and IoT apps. + +## Deep Learning with TorchSharp + +[TorchSharp](https://github.com/dotnet/TorchSharp/) is an open source set of bindings for the Pytorch engine usable for deep-learning from F#. Examples in F# are available in [TorchSharpExamples](https://github.com/dotnet/TorchSharpExamples). + +## FsLab + +[FsLab](https://fslab.org/) is an F# community incubation space for data science with F#. + +## See also + +- [F# Notebooks](../tools/notebooks.md) +- [A Guide to Data Access with F#](https://fsharp.org/guides/data-access/) +- [A Guide to Data Science with F#](https://fsharp.org/guides/data-science/) diff --git a/docs/fsharp/scenarios/web-development.md b/docs/fsharp/scenarios/web-development.md new file mode 100644 index 0000000000000..27aca7c7c5533 --- /dev/null +++ b/docs/fsharp/scenarios/web-development.md @@ -0,0 +1,39 @@ +--- +title: F# for Web Development +description: Learn about web development options with F#. +ms.date: 11/03/2021 +--- +# F# for Web Development + +F# excels at building efficient, scalable, and robust web solutions. This article gives links to some significant resources related to web programming with F#. Some frameworks for web programming with F# are listed below. + +Other web development options are documented in the F# Software Foundation's [Guide to Web Programming with F#](https://fsharp.org/guides/web). + +## ASP.NET Core + +[ASP.NET Core](/aspnet/core/) ASP.NET Core is a modern, cross-platform, high-performance, open-source framework for building modern, cloud-based, Internet-connected applications. It runs on .NET Core and supports F# out of the box. If you install the .NET SDK, there are F# templates available via the `dotnet new` command. + +## Giraffe + +[Giraffe](https://github.com/giraffe-fsharp/Giraffe#giraffe) is a community-driven F# library for building rich web applications with superb performance. It has been specifically designed with ASP.NET Core in mind and can be added into ASP.NET Core pipelines. + +## Saturn + +[Saturn](https://saturnframework.org/) is a community-driven F# web development framework that implements the server-side MVC pattern. Many of its components and concepts will seem familiar to anyone with experience in other web frameworks like Ruby on Rails or Python’s Django. It’s built on top of Giraffe and ASP.NET Core - a modern, cross-platform, high-performance development platform for building cloud-ready web applications. + +## Fable + +[Fable](https://fable.io/) is a compiler that brings F# into the JavaScript ecosystem. It generates modern JavaScript output, interoperates with JavaScript packages, and supports multiple development models including React. + +## SAFE Stack + +[SAFE Stack](https://safe-stack.github.io/) is a community-driven technology stack for functional-first web applications using Azure. SAFE Stack allows you to quickly develop compelling web applications that use industry-standard technologies whilst using F# to ensure an enjoyable development experience. SAFE includes Giraffe, Saturn, and other components. + +## WebSharper + +[WebSharper](https://github.com/dotnet-websharper/core) is a community-driven, full-stack, functional reactive web programming technology for .NET, allowing you to develop microservices, client-server web applications, reactive SPAs, and more in F#. + +## See also + +- [F# for JavaScript](../tools/javascript.md) +- [A Guide to Web Programming with F#](https://fsharp.org/guides/web/) diff --git a/docs/fsharp/style-guide/formatting.md b/docs/fsharp/style-guide/formatting.md index 15249f5f1f43f..c1bb4f069244b 100644 --- a/docs/fsharp/style-guide/formatting.md +++ b/docs/fsharp/style-guide/formatting.md @@ -720,7 +720,7 @@ let squares = [ for x in 1..10 -> x * x ] let squares' = [ for x in 1..10 do yield x * x ] ``` -Older versions of the F# language required specifying `yield` in situations where data may be generated conditionally, or there may be consecutive expressions to be evaluated. Prefer omitting these `yield` keywords unless you must compile with an older F# language version: +Older versions of F# required specifying `yield` in situations where data may be generated conditionally, or there may be consecutive expressions to be evaluated. Prefer omitting these `yield` keywords unless you must compile with an older F# language version: ```fsharp // ✔️ OK diff --git a/docs/fsharp/toc.yml b/docs/fsharp/toc.yml index aa782a8ccebd6..24349aa2d05f4 100644 --- a/docs/fsharp/toc.yml +++ b/docs/fsharp/toc.yml @@ -16,277 +16,331 @@ items: href: get-started/get-started-command-line.md - name: F# in Visual Studio for Mac href: get-started/get-started-with-visual-studio-for-mac.md -- name: Tour of F# - href: tour.md -- name: Tutorials - items: - - name: Functional Programming Concepts - href: tutorials/functional-programming-concepts.md - - name: Asynchronous Programming - href: tutorials/async.md - - name: Type Providers - href: tutorials/type-providers/index.md - items: - - name: Create a Type Provider - href: tutorials/type-providers/creating-a-type-provider.md - - name: Type provider Security - href: tutorials/type-providers/type-provider-security.md - - name: Troubleshooting Type Providers - href: tutorials/type-providers/troubleshooting-type-providers.md -- name: What's new in F# - items: - - name: F# 6 - href: whats-new/fsharp-6.md - - name: F# 5 - href: whats-new/fsharp-50.md - - name: F# 4.7 - href: whats-new/fsharp-47.md - - name: F# 4.6 - href: whats-new/fsharp-46.md - - name: F# 4.5 - href: whats-new/fsharp-45.md -- name: F# language reference - href: language-reference/index.md +- name: F# language guide items: - - name: Keyword Reference - href: language-reference/keyword-reference.md - - name: Symbol and Operator Reference - href: language-reference/symbol-and-operator-reference/index.md + - name: Overview + href: language-reference/index.md + - name: Literals + href: language-reference/literals.md + - name: Strings + href: language-reference/strings.md items: - - name: Arithmetic Operators - href: language-reference/symbol-and-operator-reference/arithmetic-operators.md - - name: Boolean Operators - href: language-reference/symbol-and-operator-reference/boolean-operators.md - - name: Bitwise Operators - href: language-reference/symbol-and-operator-reference/bitwise-operators.md - - name: Nullable Operators - href: language-reference/symbol-and-operator-reference/nullable-operators.md - - name: Functions - href: language-reference/functions/index.md + - name: Interpolated strings + href: language-reference/interpolated-strings.md + - name: Values + href: language-reference/values/index.md + - name: let Bindings items: - - name: let Bindings + - name: Overview href: language-reference/functions/let-bindings.md - name: do Bindings href: language-reference/functions/do-bindings.md - - name: "Lambda Expressions: the fun keyword" - href: language-reference/functions/lambda-expressions-the-fun-keyword.md - - name: "Recursive Functions: the rec keyword" + - name: Fixed keyword + href: language-reference/fixed.md + - name: Functions + items: + - name: Functions + href: language-reference/functions/index.md + - name: Recursive Functions href: language-reference/functions/recursive-functions-the-rec-keyword.md - - name: Entry Point - href: language-reference/functions/entry-point.md - - name: External Functions - href: language-reference/functions/external-functions.md - name: Inline Functions href: language-reference/functions/inline-functions.md - - name: Values - href: language-reference/values/index.md + - name: Function Expressions + href: language-reference/functions/lambda-expressions-the-fun-keyword.md + - name: Loops and conditionals items: - - name: Null Values - href: language-reference/values/null-values.md - - name: Literals - href: language-reference/literals.md - - name: F# Types - href: language-reference/fsharp-types.md - - name: Type Inference - href: language-reference/type-inference.md - - name: Basic Types - href: language-reference/basic-types.md - - name: Unit Type - href: language-reference/unit-type.md - - name: Strings - href: language-reference/strings.md - - name: Interpolated strings - href: language-reference/interpolated-strings.md - - name: Tuples - href: language-reference/tuples.md - - name: F# Collection Types - href: language-reference/fsharp-collection-types.md - - name: Lists - href: language-reference/lists.md - - name: Arrays - href: language-reference/arrays.md - - name: Sequences - href: language-reference/sequences.md - - name: Slices - href: language-reference/slices.md - - name: Options - href: language-reference/options.md - - name: Value Options - href: language-reference/value-options.md - - name: Results - href: language-reference/results.md - - name: Generics - href: language-reference/generics/index.md + - name: "if...then...else" + href: language-reference/conditional-expressions-if-then-else.md + - name: "for...in loops" + href: language-reference/loops-for-in-expression.md + - name: "for...to loops" + href: language-reference/loops-for-to-expression.md + - name: "while...do loops" + href: language-reference/loops-while-do-expression.md + - name: Pattern matching items: + - name: Overview + href: language-reference/pattern-matching.md + - name: Match Expressions + href: language-reference/match-expressions.md + - name: Active Patterns + href: language-reference/active-patterns.md + - name: Exception handling + items: + - name: Overview + href: language-reference/exception-handling/index.md + - name: Exception Types + href: language-reference/exception-handling/exception-types.md + - name: The try...with Expression + href: language-reference/exception-handling/the-try-with-expression.md + - name: The try...finally Expression + href: language-reference/exception-handling/the-try-finally-expression.md + - name: The use Keyword + href: language-reference/resource-management-the-use-keyword.md + - name: The raise & reraise Functions + href: language-reference/exception-handling/the-raise-function.md + - name: The failwith Function + href: language-reference/exception-handling/the-failwith-function.md + - name: The invalidArg Function + href: language-reference/exception-handling/the-invalidArg-function.md + - name: Assertions + href: language-reference/assertions.md + - name: Types and inference + items: + - name: Overview + href: language-reference/fsharp-types.md + - name: Basic Types + href: language-reference/basic-types.md + - name: Unit Type + href: language-reference/unit-type.md + - name: Type Inference + href: language-reference/type-inference.md + - name: Type Abbreviations + href: language-reference/type-abbreviations.md + - name: Casting and Conversions + href: language-reference/casting-and-conversions.md + - name: Generics + href: language-reference/generics/index.md - name: Automatic Generalization href: language-reference/generics/automatic-generalization.md - name: Constraints href: language-reference/generics/constraints.md - name: Statically Resolved Type Parameters href: language-reference/generics/statically-resolved-type-parameters.md - - name: Records - href: language-reference/records.md - - name: Anonymous Records - href: language-reference/anonymous-records.md - - name: Copy and Update Record Expressions - href: language-reference/copy-and-update-record-expressions.md - - name: Discriminated Unions - href: language-reference/discriminated-unions.md - - name: Enumerations - href: language-reference/enumerations.md - - name: Type Abbreviations - href: language-reference/type-abbreviations.md - - name: Classes - href: language-reference/classes.md - - name: Structures - href: language-reference/structures.md - - name: Nullable value types - href: language-reference/nullable-value-types.md - - name: Inheritance - href: language-reference/inheritance.md - - name: Interfaces - href: language-reference/interfaces.md - - name: Abstract Classes - href: language-reference/abstract-classes.md - - name: Members - href: language-reference/members/index.md + - name: Flexible Types + href: language-reference/flexible-types.md + - name: Units of Measure + href: language-reference/units-of-measure.md + - name: Byrefs + href: language-reference/byrefs.md + - name: Tuples, options, results + items: + - name: Tuples + href: language-reference/tuples.md + - name: Options + href: language-reference/options.md + - name: Value Options + href: language-reference/value-options.md + - name: Results + href: language-reference/results.md + - name: Collections items: - - name: let Bindings in Classes + - name: Collections + href: language-reference/fsharp-collection-types.md + - name: Lists + href: language-reference/lists.md + - name: Arrays + href: language-reference/arrays.md + - name: Slices + href: language-reference/slices.md + - name: Sequences + href: language-reference/sequences.md + - name: Reference cells + href: language-reference/reference-cells.md + - name: Records and unions + items: + - name: Records + href: language-reference/records.md + items: + - name: Copy and update expressions + href: language-reference/copy-and-update-record-expressions.md + - name: Anonymous records + href: language-reference/anonymous-records.md + - name: Discriminated unions + href: language-reference/discriminated-unions.md + - name: Object programming + items: + - name: Classes + href: language-reference/classes.md + - name: Interfaces + href: language-reference/interfaces.md + - name: Members + href: language-reference/members/index.md + - name: Constructors + href: language-reference/members/constructors.md + - name: let bindings in classes href: language-reference/members/let-bindings-in-classes.md - - name: do Bindings in Classes + - name: do bindings in classes href: language-reference/members/do-bindings-in-classes.md - name: Properties href: language-reference/members/properties.md - - name: Indexed Properties - href: language-reference/members/indexed-properties.md - name: Methods href: language-reference/members/methods.md - - name: Constructors - href: language-reference/members/constructors.md + - name: Method parameters + href: language-reference/parameters-and-arguments.md + - name: Indexed properties + href: language-reference/members/indexed-properties.md + - name: Operator overloading + href: language-reference/operator-overloading.md + - name: Explicit fields + href: language-reference/members/explicit-fields-the-val-keyword.md + - name: Object expressions + href: language-reference/object-expressions.md + - name: Type extensions + href: language-reference/type-extensions.md + - name: Inheritance + href: language-reference/inheritance.md + - name: Abstract classes + href: language-reference/abstract-classes.md + - name: Structs + items: + - name: Struct types + href: language-reference/structs.md + - name: Computations + items: + - name: Computation expressions + href: language-reference/computation-expressions.md + - name: Async expressions + href: language-reference/async-expressions.md + - name: Task expressions + href: language-reference/task-expressions.md + - name: Lazy expressions + href: language-reference/lazy-expressions.md + - name: Organizing code + items: + - name: Namespaces + href: language-reference/namespaces.md + - name: Modules + href: language-reference/modules.md + - name: open declarations + href: language-reference/import-declarations-the-open-keyword.md + - name: Signature files + href: language-reference/signature-files.md + - name: Access control + href: language-reference/access-control.md + - name: XML documentation + href: language-reference/xml-documentation.md + - name: Entry point + href: language-reference/functions/entry-point.md + - name: Queries + items: + - name: Query expressions + href: language-reference/query-expressions.md + - name: Interoperability + items: + - name: Null values + href: language-reference/values/null-values.md + - name: Nullable value types + href: language-reference/nullable-value-types.md + - name: Delegates + href: language-reference/delegates.md + - name: Enums + href: language-reference/enumerations.md - name: Events href: language-reference/members/events.md - - name: "Explicit Fields: The `val` Keyword" - href: language-reference/members/explicit-fields-the-val-keyword.md - - name: Type Extensions - href: language-reference/type-extensions.md - - name: Parameters and Arguments - href: language-reference/parameters-and-arguments.md - - name: Operator Overloading - href: language-reference/operator-overloading.md - - name: Flexible Types - href: language-reference/flexible-types.md - - name: Delegates - href: language-reference/delegates.md - - name: Object Expressions - href: language-reference/object-expressions.md - - name: Casting and Conversions - href: language-reference/casting-and-conversions.md - - name: Access Control - href: language-reference/access-control.md - - name: "Conditional Expressions: if...then...else" - href: language-reference/conditional-expressions-if-then-else.md - - name: Match Expressions - href: language-reference/match-expressions.md - - name: Pattern Matching - href: language-reference/pattern-matching.md - - name: Active Patterns - href: language-reference/active-patterns.md - - name: "Loops: for...to Expression" - href: language-reference/loops-for-to-expression.md - - name: "Loops: for...in Expression" - href: language-reference/loops-for-in-expression.md - - name: "Loops: while...do Expression" - href: language-reference/loops-while-do-expression.md - - name: Assertions - href: language-reference/assertions.md - - name: Exception Handling - href: language-reference/exception-handling/index.md + - name: External functions + href: language-reference/functions/external-functions.md + - name: Reflection items: - - name: Exception Types - href: language-reference/exception-handling/exception-types.md - - name: The try...with Expression - href: language-reference/exception-handling/the-try-with-expression.md - - name: The try...finally Expression - href: language-reference/exception-handling/the-try-finally-expression.md - - name: The raise & reraise Functions - href: language-reference/exception-handling/the-raise-function.md - - name: The failwith Function - href: language-reference/exception-handling/the-failwith-function.md - - name: The invalidArg Function - href: language-reference/exception-handling/the-invalidArg-function.md - - name: Attributes - href: language-reference/attributes.md - - name: "Resource Management: the use Keyword" - href: language-reference/resource-management-the-use-keyword.md - - name: Namespaces - href: language-reference/namespaces.md - - name: Modules - href: language-reference/modules.md - - name: "Import Declarations: The open Keyword" - href: language-reference/import-declarations-the-open-keyword.md - - name: Signature Files - href: language-reference/signature-files.md - - name: Units of Measure - href: language-reference/units-of-measure.md - - name: Plain Text Formatting - href: language-reference/plaintext-formatting.md - - name: XML Documentation - href: language-reference/xml-documentation.md - - name: Lazy Expressions - href: language-reference/lazy-expressions.md - - name: Computation Expressions - href: language-reference/computation-expressions.md - - name: Async Expressions - href: language-reference/async-expressions.md - - name: Task Expressions - href: language-reference/task-expressions.md - - name: Query Expressions - href: language-reference/query-expressions.md - - name: Code Quotations - href: language-reference/code-quotations.md - - name: Fixed keyword - href: language-reference/fixed.md - - name: Byrefs - href: language-reference/byrefs.md - - name: Reference Cells - href: language-reference/reference-cells.md - - name: nameof - href: language-reference/nameof.md - - name: Compiler Directives + - name: Attributes + href: language-reference/attributes.md + - name: Code quotations + href: language-reference/code-quotations.md + - name: nameof + href: language-reference/nameof.md + - name: Caller information + href: language-reference/caller-information.md + - name: Source line, file, and path identifiers + href: language-reference/source-line-file-path-identifiers.md + - name: Plain text formatting + href: language-reference/plaintext-formatting.md + - name: Type providers + items: + - name: Overview + href: tutorials/type-providers/index.md + - name: Create a Type Provider + href: tutorials/type-providers/creating-a-type-provider.md + - name: Type provider Security + href: tutorials/type-providers/type-provider-security.md + - name: Troubleshooting Type Providers + href: tutorials/type-providers/troubleshooting-type-providers.md +- name: F# language reference + items: + - name: Compiler directives href: language-reference/compiler-directives.md - - name: Compiler Options + - name: Keyword reference + href: language-reference/keyword-reference.md + - name: Verbose syntax + href: language-reference/verbose-syntax.md + - name: Symbol and operator reference + items: + - name: Overview + href: language-reference/symbol-and-operator-reference/index.md + - name: Arithmetic operators + href: language-reference/symbol-and-operator-reference/arithmetic-operators.md + - name: Boolean operators + href: language-reference/symbol-and-operator-reference/boolean-operators.md + - name: Bitwise operators + href: language-reference/symbol-and-operator-reference/bitwise-operators.md + - name: Nullable operators + href: language-reference/symbol-and-operator-reference/nullable-operators.md + - name: Compiler options href: language-reference/compiler-options.md - - name: F# Interactive Options + - name: F# Interactive options href: language-reference/fsharp-interactive-options.md - - name: Source Line, File, and Path Identifiers - href: language-reference/source-line-file-path-identifiers.md - - name: Caller Information - href: language-reference/caller-information.md - - name: Verbose Syntax - href: language-reference/verbose-syntax.md - name: Compiler errors and warnings - href: language-reference/compiler-messages/index.md -- name: F# Tools + href: language-reference/compiler-messages/ +- name: Tutorials items: + - name: Tour of F# + href: tour.md + - name: Functional programming concepts + href: tutorials/functional-programming-concepts.md + - name: Asynchronous programming + href: tutorials/async.md + - name: Using functions + href: tutorials/using-functions.md +- name: What's new + items: + - name: F# 6 + href: whats-new/fsharp-6.md + - name: F# 5 + href: whats-new/fsharp-50.md + - name: F# 4.7 + href: whats-new/fsharp-47.md + - name: F# 4.6 + href: whats-new/fsharp-46.md + - name: F# 4.5 + href: whats-new/fsharp-45.md +- name: F# tools + items: + - name: F# Development tools + href: tools/development-tools.md - name: F# Interactive href: tools/fsharp-interactive/index.md + - name: F# Notebooks + href: tools/notebooks.md + - name: F# for JavaScript + href: tools/javascript.md - name: F# style guide - href: style-guide/index.md items: + - name: Overview + href: style-guide/index.md - name: F# code formatting guidelines href: style-guide/formatting.md - name: F# coding conventions href: style-guide/conventions.md - name: F# component design guidelines href: style-guide/component-design-guidelines.md -- name: Use F# on Azure - href: using-fsharp-on-azure/index.md +- name: F# for machine learning + href: scenarios/machine-learning.md +- name: F# for web development + href: scenarios/web-development.md +- name: F# for Azure items: - - name: Get started with Azure Blob Storage using F# - href: using-fsharp-on-azure/blob-storage.md - - name: Get started with Azure File Storage using F# - href: using-fsharp-on-azure/file-storage.md - - name: Get started with Azure Queue Storage using F# - href: using-fsharp-on-azure/queue-storage.md - - name: Get started with Azure Table Storage using F# - href: using-fsharp-on-azure/table-storage.md + - name: Apache Spark on Azure + href: using-fsharp-on-azure/apache-spark.md + - name: Azure resource management + href: using-fsharp-on-azure/deploying-and-managing.md + - name: Azure storage + items: + - name: Blob Storage + href: using-fsharp-on-azure/blob-storage.md + - name: File Storage + href: using-fsharp-on-azure/file-storage.md + - name: Queue Storage + href: using-fsharp-on-azure/queue-storage.md + - name: Table Storage + href: using-fsharp-on-azure/table-storage.md + - name: Other Azure services + href: using-fsharp-on-azure/other-azure-services.md diff --git a/docs/fsharp/tools/development-tools.md b/docs/fsharp/tools/development-tools.md new file mode 100644 index 0000000000000..519e461269494 --- /dev/null +++ b/docs/fsharp/tools/development-tools.md @@ -0,0 +1,40 @@ +--- +title: F# Development Tools +description: Learn about development tools for F#. +ms.date: 11/03/2021 +--- +# F# Development Tools + +This article describes some of the primary development tools used with F#. + +## .NET Command-line Tools + +You can install command-line tools for F# in multiple ways, depending on your environment. See [Install F#](../get-started/install-fsharp.md). + +## Integrated Development Environments (IDEs) + +### F# with Visual Studio + +F# can be installed as part of [Visual Studio](https://visualstudio.microsoft.com/). See [Getting Started with F# in Visual Studio](../get-started/get-started-visual-studio.md). + +### F# with Visual Studio Code + +F# can be installed as part of [Visual Studio Code](https://code.visualstudio.com/). See [Getting Started with F# in Visual Studio Code](../get-started/get-started-vscode.md). + +### F# with Visual Studio for Mac + +F# can be installed as part of [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/). See [Getting Started with F# in Visual Studio for Mac](../get-started/get-started-with-visual-studio-for-mac.md). + +### Other development environments + +Other IDEs are available for F#, see [F# Tools](https://dotnet.microsoft.com/languages/fsharp/tools) + +## Community Tools + +Many tools and libraries for F# are provided by the F# community. These include: + +* [Fantomas](https://github.com/fsprojects/fantomas#fantomas) - The F# code formatting tool +* [FSharpLint](https://fsprojects.github.io/FSharpLint/) - An F# code checking tool +* [FAKE](https://fsprojects.github.io/FAKE/) - An F# build automation tool + +For more comprehensive lists, see the F# Software Foundation's [Guide to F# Community Projects](https://fsharp.org/community/projects/), or search on the web. diff --git a/docs/fsharp/tools/fsharp-interactive/index.md b/docs/fsharp/tools/fsharp-interactive/index.md index e637f4edea88c..3e493e345fe2b 100644 --- a/docs/fsharp/tools/fsharp-interactive/index.md +++ b/docs/fsharp/tools/fsharp-interactive/index.md @@ -7,7 +7,7 @@ f1_keywords: --- # Interactive programming with F\# -F# Interactive (dotnet fsi) is used to run F# code interactively at the console, or to execute F# scripts. In other words, F# interactive executes a REPL (Read, Evaluate, Print Loop) for the F# language. +F# Interactive (dotnet fsi) is used to run F# code interactively at the console, or to execute F# scripts. In other words, F# interactive executes a REPL (Read, Evaluate, Print Loop) for F#. To run F# Interactive from the console, run `dotnet fsi`. You will find `dotnet fsi` in any .NET SDK. diff --git a/docs/fsharp/tools/img/fsharp-mlnet-notebook.png b/docs/fsharp/tools/img/fsharp-mlnet-notebook.png new file mode 100644 index 0000000000000..f27231b85bca7 Binary files /dev/null and b/docs/fsharp/tools/img/fsharp-mlnet-notebook.png differ diff --git a/docs/fsharp/tools/javascript.md b/docs/fsharp/tools/javascript.md new file mode 100644 index 0000000000000..851c3ce54be1e --- /dev/null +++ b/docs/fsharp/tools/javascript.md @@ -0,0 +1,21 @@ +--- +title: F# Tools for JavaScript +description: Learn about F# tools for executing your code as JavaScript. +ms.date: 11/03/2021 +--- +# F# for JavaScript + +F# can execute as JavaScript code through two community-provided open source toolchains. This allows F# code to be used for client-side and full-stack web development. + +## Fable + +[Fable](https://fable.io/) is a compiler that brings F# into the JavaScript ecosystem. It generates modern JavaScript output, interoperates with JavaScript packages, and supports multiple development models including React. + +## WebSharper + +[WebSharper](https://github.com/dotnet-websharper/core) - Provides full-stack, functional reactive web programming for .NET, allowing you to develop microservices, client-server web applications, reactive SPAs, and more in C# or F#. + +## See also + +- [F# for Web Development](../scenarios/web-development.md) +- [A Guide to Web Programming with F#](https://fsharp.org/guides/web/) diff --git a/docs/fsharp/tools/notebooks.md b/docs/fsharp/tools/notebooks.md new file mode 100644 index 0000000000000..8a09b694145d7 --- /dev/null +++ b/docs/fsharp/tools/notebooks.md @@ -0,0 +1,19 @@ +--- +title: F# Notebooks +description: Learn about developing notebooks with F#. +ms.date: 11/03/2021 +--- +# F# notebooks + +F# is well suited to notebook programming because of its ordered declarations and scripting constructs. + +[.NET Interactive](https://github.com/dotnet/interactive/#net-interactive-) F# notebooks can be used with [Jupyter](https://github.com/dotnet/interactive/#jupyter-and-nteract), [Visual Studio Code](https://github.com/dotnet/interactive#notebooks-with-net), and [Visual Studio](https://marketplace.visualstudio.com/items?itemName=MLNET.notebook). + +![.NET Interactive notebook using ML.NET](./img/fsharp-mlnet-notebook.png) + +## See also + +- [Machine Learning with F#](../scenarios/machine-learning.md) +- [.NET Interactive](https://github.com/dotnet/interactive/) +- [A Guide to Data Access with F#](https://fsharp.org/guides/data-access/) +- [A Guide to Data Science with F#](https://fsharp.org/guides/data-science/) diff --git a/docs/fsharp/tour.md b/docs/fsharp/tour.md index b69886b575c53..4d0ea5275de2f 100644 --- a/docs/fsharp/tour.md +++ b/docs/fsharp/tour.md @@ -1,11 +1,11 @@ --- title: Tour of F# description: Examine some of the key features of the F# programming language in this tour with code samples. -ms.date: 10/29/2021 +ms.date: 03/11/2021 --- # Tour of F\# -The best way to learn about F# is to read and write F# code. This article will act as a tour through some of the key features of the F# language and give you some code snippets that you can execute on your machine. To learn about setting up a development environment, check out [Getting Started](get-started/index.md). +The best way to learn about F# is to read and write F# code. This article will act as a tour through some of the key features of F# and give you some code snippets that you can execute on your machine. To learn about setting up a development environment, check out [Getting Started](get-started/index.md). There are two primary concepts in F#: functions and types. This tour emphasizes features of the language that fall into these two concepts. @@ -15,7 +15,7 @@ If you don't have F# installed on your machine, you can execute all of the sampl ## Functions and Modules -The most fundamental pieces of any F# program are ***functions*** organized into ***modules***. [Functions](./language-reference/functions/index.md) perform work on inputs to produce outputs, and they are organized under [Modules](./language-reference/modules.md), which are the primary way you group things in F#. They are defined using the [`let` binding](./language-reference/functions/let-bindings.md), which give the function a name and define its arguments. +The most fundamental pieces of any F# program are ***functions*** organized into ***modules***. [Functions](language-reference/functions/index.md) perform work on inputs to produce outputs, and they are organized under [Modules](language-reference/modules.md), which are the primary way you group things in F#. They are defined using the [`let` binding](language-reference/functions/let-bindings.md), which give the function a name and define its arguments. [!code-fsharp[BasicFunctions](~/samples/snippets/fsharp/tour.fs#L101-L133)] @@ -35,13 +35,13 @@ Here's what Boolean values and performing basic conditional logic looks like: [!code-fsharp[Bools](~/samples/snippets/fsharp/tour.fs#L142-L152)] -And here's what basic [string](./language-reference/strings.md) manipulation looks like: +And here's what basic [string](language-reference/strings.md) manipulation looks like: [!code-fsharp[Strings](~/samples/snippets/fsharp/tour.fs#L158-L180)] ## Tuples -[Tuples](./language-reference/tuples.md) are a big deal in F#. They are a grouping of unnamed but ordered values that can be treated as values themselves. Think of them as values which are aggregated from other values. They have many uses, such as conveniently returning multiple values from a function, or grouping values for some ad-hoc convenience. +[Tuples](language-reference/tuples.md) are a big deal in F#. They are a grouping of unnamed but ordered values that can be treated as values themselves. Think of them as values which are aggregated from other values. They have many uses, such as conveniently returning multiple values from a function, or grouping values for some ad-hoc convenience. [!code-fsharp[Tuples](~/samples/snippets/fsharp/tour.fs#L186-L203)] @@ -51,33 +51,33 @@ You can also create `struct` tuples. These also interoperate fully with C#7/Vis It's important to note that because `struct` tuples are value types, they cannot be implicitly converted to reference tuples, or vice versa. You must explicitly convert between a reference and struct tuple. -## Pipelines and Composition +## Pipelines -Pipe operators such as `|>` are used extensively when processing data in F#. These operators are functions that allow you to establish "pipelines" of functions in a flexible manner. The following example walks through how you can take advantage of these operators to build a simple functional pipeline: +The pipe operator `|>` is used extensively when processing data in F#. This operator allow you to establish "pipelines" of functions in a flexible manner. The following example walks through how you can take advantage of these operators to build a simple functional pipeline: [!code-fsharp[Pipelines](~/samples/snippets/fsharp/tour.fs#L227-L302)] -The previous sample made use of many features of F#, including list processing functions, first-class functions, and [partial application](./language-reference/functions/index.md#partial-application-of-arguments). Although these are advanced concepts, it should be clear how easily functions can be used to process data when building pipelines. +The previous sample made use of many features of F#, including list processing functions, first-class functions, and [partial application](language-reference/functions/index.md#partial-application-of-arguments). Although these are advanced concepts, it should be clear how easily functions can be used to process data when building pipelines. ## Lists, Arrays, and Sequences Lists, Arrays, and Sequences are three primary collection types in the F# core library. -[Lists](./language-reference/lists.md) are ordered, immutable collections of elements of the same type. They are singly linked lists, which means they are meant for enumeration, but a poor choice for random access and concatenation if they're large. This in contrast to Lists in other popular languages, which typically do not use a singly linked list to represent Lists. +[Lists](language-reference/lists.md) are ordered, immutable collections of elements of the same type. They are singly linked lists, which means they are meant for enumeration, but a poor choice for random access and concatenation if they're large. This in contrast to Lists in other popular languages, which typically do not use a singly linked list to represent Lists. [!code-fsharp[Lists](~/samples/snippets/fsharp/tour.fs#L311-L363)] -[Arrays](./language-reference/arrays.md) are fixed-size, *mutable* collections of elements of the same type. They support fast random access of elements, and are faster than F# lists because they are just contiguous blocks of memory. +[Arrays](language-reference/arrays.md) are fixed-size, *mutable* collections of elements of the same type. They support fast random access of elements, and are faster than F# lists because they are just contiguous blocks of memory. [!code-fsharp[Arrays](~/samples/snippets/fsharp/tour.fs#L372-L413)] -[Sequences](./language-reference/sequences.md) are a logical series of elements, all of the same type. These are a more general type than Lists and Arrays, capable of being your "view" into any logical series of elements. They also stand out because they can be ***lazy***, which means that elements can be computed only when they are needed. +[Sequences](language-reference/sequences.md) are a logical series of elements, all of the same type. These are a more general type than Lists and Arrays, capable of being your "view" into any logical series of elements. They also stand out because they can be ***lazy***, which means that elements can be computed only when they are needed. [!code-fsharp[Sequences](~/samples/snippets/fsharp/tour.fs#L424-L458)] ## Recursive Functions -Processing collections or sequences of elements is typically done with [recursion](./language-reference/functions/index.md#recursive-functions) in F#. Although F# has support for loops and imperative programming, recursion is preferred because it is easier to guarantee correctness. +Processing collections or sequences of elements is typically done with [recursion](language-reference/functions/index.md#recursive-functions) in F#. Although F# has support for loops and imperative programming, recursion is preferred because it is easier to guarantee correctness. > [!NOTE] > The following example makes use of the pattern matching via the `match` expression. This fundamental construct is covered later in this article. @@ -90,7 +90,7 @@ F# also has full support for Tail Call Optimization, which is a way to optimize Record and Union types are two fundamental data types used in F# code, and are generally the best way to represent data in an F# program. Although this makes them similar to classes in other languages, one of their primary differences is that they have structural equality semantics. This means that they are "natively" comparable and equality is straightforward - just check if one is equal to the other. -[Records](./language-reference/records.md) are an aggregate of named values, with optional members (such as methods). If you're familiar with C# or Java, then these should feel similar to POCOs or POJOs - just with structural equality and less ceremony. +[Records](language-reference/records.md) are an aggregate of named values, with optional members (such as methods). If you're familiar with C# or Java, then these should feel similar to POCOs or POJOs - just with structural equality and less ceremony. [!code-fsharp[Records](~/samples/snippets/fsharp/tour.fs#L516-L568)] @@ -98,7 +98,7 @@ You can also represent Records as structs. This is done with the `[]` at [!code-fsharp[Records](~/samples/snippets/fsharp/tour.fs#L573-L577)] -[Discriminated Unions (DUs)](./language-reference/discriminated-unions.md) are values that could be a number of named forms or cases. Data stored in the type can be one of several distinct values. +[Discriminated Unions (DUs)](language-reference/discriminated-unions.md) are values that could be a number of named forms or cases. Data stored in the type can be one of several distinct values. [!code-fsharp[Unions](~/samples/snippets/fsharp/tour.fs#L584-L640)] @@ -114,56 +114,43 @@ Additionally, DUs also support recursive definitions, allowing you to easily rep Because DUs allow you to represent the recursive structure of the tree in the data type, operating on this recursive structure is straightforward and guarantees correctness. It is also supported in pattern matching, as shown below. -Additionally, you can represent DUs as `struct`s with the `[]` attribute: - -[!code-fsharp[Unions](~/samples/snippets/fsharp/tour.fs#L704-L708)] - -However, there are two key things to keep in mind when doing so: - -1. A struct DU cannot be recursively defined. -2. A struct DU must have unique names for each of its cases. - -Failure to follow the above will result in a compilation error. - ## Pattern Matching -[Pattern Matching](./language-reference/pattern-matching.md) is the F# language feature that enables correctness for operating on F# types. In the above samples, you probably noticed quite a bit of `match x with ...` syntax. This construct allows the compiler, which can understand the "shape" of data types, to force you to account for all possible cases when using a data type through what is known as Exhaustive Pattern Matching. This is incredibly powerful for correctness, and can be cleverly used to "lift" what would normally be a run-time concern into a compile-time concern. +[Pattern Matching](language-reference/pattern-matching.md) is the F# feature that enables correctness for operating on F# types. In the above samples, you probably noticed quite a bit of `match x with ...` syntax. This construct allows the compiler, which can understand the "shape" of data types, to force you to account for all possible cases when using a data type through what is known as Exhaustive Pattern Matching. This is incredibly powerful for correctness, and can be cleverly used to "lift" what would normally be a run-time concern into a compile-time concern. [!code-fsharp[PatternMatching](~/samples/snippets/fsharp/tour.fs#L717-L743)] -Something you may have noticed is the use of the `_` pattern. This is known as the [Wildcard Pattern](./language-reference/pattern-matching.md#wildcard-pattern), which is a way of saying "I don't care what something is". Although convenient, you can accidentally bypass Exhaustive Pattern Matching and no longer benefit from compile-time enforcements if you aren't careful in using `_`. It is best used when you don't care about certain pieces of a decomposed type when pattern matching, or the final clause when you have enumerated all meaningful cases in a pattern matching expression. +Something you may have noticed is the use of the `_` pattern. This is known as the [Wildcard Pattern](language-reference/pattern-matching.md#wildcard-pattern), which is a way of saying "I don't care what something is". Although convenient, you can accidentally bypass Exhaustive Pattern Matching and no longer benefit from compile-time enforcements if you aren't careful in using `_`. It is best used when you don't care about certain pieces of a decomposed type when pattern matching, or the final clause when you have enumerated all meaningful cases in a pattern matching expression. In the following example, the `_` case is used when a parse operation fails. [!code-fsharp[PatternMatching](~/samples/snippets/fsharp/tour.fs#L745-L771)] -[Active Patterns](./language-reference/active-patterns.md) are another powerful construct to use with pattern matching. They allow you to partition input data into custom forms, decomposing them at the pattern match call site. They can also be parameterized, thus allowing to define the partition as a function. Expanding the previous example to support Active Patterns looks something like this: +[Active Patterns](language-reference/active-patterns.md) are another powerful construct to use with pattern matching. They allow you to partition input data into custom forms, decomposing them at the pattern match call site. They can also be parameterized, thus allowing to define the partition as a function. Expanding the previous example to support Active Patterns looks something like this: [!code-fsharp[ActivePatterns](~/samples/snippets/fsharp/tour.fs#L777-L795)] -## Optional Types +## Options One special case of Discriminated Union types is the Option Type, which is so useful that it's a part of the F# core library. -[The Option Type](./language-reference/options.md) is a type that represents one of two cases: a value, or nothing at all. It is used in any scenario where a value may or may not result from a particular operation. This then forces you to account for both cases, making it a compile-time concern rather than a runtime concern. These are often used in APIs where `null` is used to represent "nothing" instead, thus eliminating the need to worry about `NullReferenceException` in many circumstances. +[The Option Type](language-reference/options.md) is a type that represents one of two cases: a value, or nothing at all. It is used in any scenario where a value may or may not result from a particular operation. This then forces you to account for both cases, making it a compile-time concern rather than a runtime concern. These are often used in APIs where `null` is used to represent "nothing" instead, thus eliminating the need to worry about `NullReferenceException` in many circumstances. [!code-fsharp[Options](~/samples/snippets/fsharp/tour.fs#L803-L823)] ## Units of Measure -One unique feature of F#'s type system is the ability to provide context for numeric literals through Units of Measure. - -[Units of Measure](./language-reference/units-of-measure.md) allow you to associate a numeric type to a unit, such as Meters, and have functions perform work on units rather than numeric literals. This enables the compiler to verify that the types of numeric literals passed in make sense under a certain context, thus eliminating runtime errors associated with that kind of work. +F#'s type system includes the ability to provide context for numeric literals through [Units of Measure](language-reference/units-of-measure.md). Units of measure allow you to associate a numeric type to a unit, such as Meters, and have functions perform work on units rather than numeric literals. This enables the compiler to verify that the types of numeric literals passed in make sense under a certain context, thus eliminating run-time errors associated with that kind of work. [!code-fsharp[UnitsOfMeasure](~/samples/snippets/fsharp/tour.fs#L830-L851)] The F# Core library defines many SI unit types and unit conversions. To learn more, check out the [FSharp.Data.UnitSystems.SI.UnitSymbols Namespace](https://fsharp.github.io/fsharp-core-docs/reference/fsharp-data-unitsystems-si-unitsymbols.html). -## Classes and Interfaces +## Object Programming -F# also has full support for .NET classes, [Interfaces](./language-reference/interfaces.md), [Abstract Classes](./language-reference/abstract-classes.md), [Inheritance](./language-reference/inheritance.md), and so on. +F# has full support for object programming through classes, [Interfaces](language-reference/interfaces.md), [Abstract Classes](language-reference/abstract-classes.md), [Inheritance](language-reference/inheritance.md), and so on. -[Classes](./language-reference/classes.md) are types that represent .NET objects, which can have properties, methods, and events as its [Members](./language-reference/members/index.md). +[Classes](language-reference/classes.md) are types that represent .NET objects, which can have properties, methods, and events as its [Members](language-reference/members/index.md). [!code-fsharp[Classes](~/samples/snippets/fsharp/tour.fs#L860-L889)] @@ -171,7 +158,7 @@ Defining generic classes is also straightforward. [!code-fsharp[Classes](~/samples/snippets/fsharp/tour.fs#L896-L917)] -To implement an Interface, you can use either `interface ... with` syntax or an [Object Expression](./language-reference/object-expressions.md). +To implement an Interface, you can use either `interface ... with` syntax or an [Object Expression](language-reference/object-expressions.md). [!code-fsharp[Classes](~/samples/snippets/fsharp/tour.fs#L924-L943)] @@ -191,4 +178,4 @@ Classes are great for a huge number of reasons, such as when you need to represe Now that you've seen some of the primary features of the language, you should be ready to write your first F# programs! Check out [Getting Started](get-started/index.md) to learn how to set up your development environment and write some code. -Also, check out the [F# Language Reference](./language-reference/index.md) to see a comprehensive collection of conceptual content on F#. +Also, check out the [F# Language Reference](language-reference/index.md) to see a comprehensive collection of conceptual content on F#. diff --git a/docs/fsharp/tutorials/async.md b/docs/fsharp/tutorials/async.md index 76f37f628ca30..49e130a4256ff 100644 --- a/docs/fsharp/tutorials/async.md +++ b/docs/fsharp/tutorials/async.md @@ -405,6 +405,6 @@ Although F# provides some abilities to start an asynchronous computation on the ## See also - [The F# Asynchronous Programming Model](https://www.microsoft.com/research/publication/the-f-asynchronous-programming-model) -- [Jet.com's F# Async Guide](https://medium.com/jettech/f-async-guide-eb3c8a2d180a) +- [Leo Gorodinski's F# Async Guide](https://medium.com/jettech/f-async-guide-eb3c8a2d180a) - [F# for fun and profit's Asynchronous Programming guide](https://fsharpforfunandprofit.com/posts/concurrency-async-and-parallel/) - [Async in C# and F#: Asynchronous gotchas in C#](http://tomasp.net/blog/csharp-async-gotchas.aspx/) diff --git a/docs/fsharp/tutorials/type-providers/creating-a-type-provider.md b/docs/fsharp/tutorials/type-providers/creating-a-type-provider.md index 68ff1a5a6f30a..0110255984dfa 100644 --- a/docs/fsharp/tutorials/type-providers/creating-a-type-provider.md +++ b/docs/fsharp/tutorials/type-providers/creating-a-type-provider.md @@ -1,7 +1,7 @@ --- title: "Tutorial: Create a Type Provider" -description: Learn how to create your own F# type providers in F# 3.0 by examining several simple type providers to illustrate the basic concepts. -ms.date: 11/04/2019 +description: Learn how to create your own F# type providers by examining several simple type providers to illustrate the basic concepts. +ms.date: 11/04/2021 --- # Tutorial: Create a Type Provider @@ -10,15 +10,13 @@ The type provider mechanism in F# is a significant part of its support for infor The F# ecosystem contains a range of type providers for commonly used Internet and enterprise data services. For example: -- FSharp.Data includes type providers for JSON, XML, CSV and HTML document formats. +- [FSharp.Data](https://fsprojects.github.io/FSharp.Data/) includes type providers for JSON, XML, CSV and HTML document formats. -- [SQLProvider](https://fsprojects.github.io/SQLProvider/) provides strongly typed access to SQL databases through an object mapping and F# LINQ queries against these data sources. +- [SwaggerProvider](https://fsprojects.github.io/SwaggerProvider/) includes two generative type providers that generate object model and HTTP clients for APIs described by OpenApi 3.0 and Swagger 2.0 schemas. - [FSharp.Data.SqlClient](https://fsprojects.github.io/FSharp.Data.SqlClient/) has a set of type providers for compile-time checked embedding of T-SQL in F#. -- [FSharp.Data.TypeProviders](https://fsprojects.github.io/FSharp.Data.TypeProviders/) is an older set of type providers for use only with .NET Framework programming for accessing SQL, Entity Framework, OData and WSDL data services. - -Where necessary, you can create custom type providers, or you can reference type providers that others have created. For example, your organization could have a data service that provides a large and growing number of named data sets, each with its own stable data schema. You can create a type provider that reads the schemas and presents the current data sets to the programmer in a strongly typed way. +You can create custom type providers, or you can reference type providers that others have created. For example, your organization could have a data service that provides a large and growing number of named data sets, each with its own stable data schema. You can create a type provider that reads the schemas and presents the current data sets to the programmer in a strongly typed way. ## Before You Start diff --git a/docs/fsharp/using-fsharp-on-azure/apache-spark.md b/docs/fsharp/using-fsharp-on-azure/apache-spark.md new file mode 100644 index 0000000000000..5b72a430ce2d0 --- /dev/null +++ b/docs/fsharp/using-fsharp-on-azure/apache-spark.md @@ -0,0 +1,21 @@ +--- +title: Using Apache Spark with F# on Azure +description: Guide to using Azure Spark with F# +author: dsyme +ms.date: 11/04/2021 +ms.custom: "devx-track-fsharp" +--- + +# Using Apache Spark with F\# on Azure + +[Apache Spark for Azure HDInsight](/azure/hdinsight/spark/apache-spark-overview) is an open source processing framework that runs large-scale data analytics applications. [Azure Databricks](/azure/databricks/scenarios/what-is-azure-databricks) is an Apache Spark-based analytics platform optimized for the Microsoft Azure cloud services platform. Azure makes Apache Spark easy and cost effective to deploy. Develop your Spark application in F# using [.NET for Apache Spark](../../spark/what-is-apache-spark-dotnet.md), a set of .NET bindings for Apache Spark. + +* [.NET for Apache Spark F# samples](https://github.com/dotnet/spark/tree/main/examples/Microsoft.Spark.FSharp.Examples) +* [Install .NET Interactive Jupyter notebooks in Azure HDInsight](../../spark/how-to-guides/hdinsight-notebook-installation.md) +* [Submit Apache Spark jobs to Azure HDInsight](../../spark/how-to-guides/hdinsight-deploy-methods.md) +* [Submit Apache Spark jobs to Azure Databricks](../../spark/how-to-guides/databricks-deploy-methods.md) + +## Other resources + +* [Apache Spark for Azure HDInsight](/azure/hdinsight/spark/apache-spark-overview) +* [Full documentation on all Azure services](/azure/) diff --git a/docs/fsharp/using-fsharp-on-azure/blob-storage.md b/docs/fsharp/using-fsharp-on-azure/blob-storage.md index b2a6281e5d37a..85048475b78bf 100644 --- a/docs/fsharp/using-fsharp-on-azure/blob-storage.md +++ b/docs/fsharp/using-fsharp-on-azure/blob-storage.md @@ -197,30 +197,10 @@ By default, the blob data in your storage account is accessible only to storage Azure Storage supports encrypting blob data both at the client and on the server. -## Next steps - -Now that you've learned the basics of Blob storage, follow these links to learn more. - -### Tools - -- [F# AzureStorageTypeProvider](https://fsprojects.github.io/AzureStorageTypeProvider/)\ -An F# Type Provider that can be used to explore Blob, Table, and Queue Azure Storage assets and easily apply CRUD operations on them. - -- [FSharp.Azure.Storage](https://github.com/fsprojects/FSharp.Azure.Storage)\ -An F# API for using Microsoft Azure Table Storage service - -- [Microsoft Azure Storage Explorer (MASE)](/azure/vs-azure-tools-storage-manage-with-storage-explorer)\ -A free, standalone app from Microsoft that enables you to work visually with Azure Storage data on Windows, OS X, and Linux. - -### Blob storage reference +### See also - [Azure Storage APIs for .NET](/dotnet/api/overview/azure/storage) - [Azure Storage Services REST API Reference](/rest/api/storageservices/) - -### Related guides - -- [Azure Blob Storage Samples for .NET](/samples/azure-samples/storage-blob-dotnet-getting-started/storage-blob-dotnet-getting-started/) - [Get started with AzCopy](/azure/storage/common/storage-use-azcopy-v10) - [Configure Azure Storage connection strings](/azure/storage/common/storage-configure-connection-string) -- [Azure Storage Team Blog](/archive/blogs/windowsazurestorage/) - [Quickstart: Use .NET to create a blob in object storage](/azure/storage/blobs/storage-quickstart-blobs-dotnet) diff --git a/docs/fsharp/using-fsharp-on-azure/deploying-and-managing.md b/docs/fsharp/using-fsharp-on-azure/deploying-and-managing.md new file mode 100644 index 0000000000000..307e34467c7f9 --- /dev/null +++ b/docs/fsharp/using-fsharp-on-azure/deploying-and-managing.md @@ -0,0 +1,25 @@ +--- +title: Deploying and Managing Azure Resources with F\# +description: Learn how to deploy and manage Azure resources with F\# +author: dsyme +ms.date: 11/04/2021 +ms.custom: "devx-track-fsharp" +--- + +# Deploying and Managing Azure Resources with F\# + +F# may be used to configure, deploy, and manage Azure resources. This articles provides links for the F#-specific technology [Farmer](https://compositionalit.github.io/farmer/). + +Other options for Azure resource deployment and management are documented in [Azure Resource Manager](/azure/azure-resource-manager/). This includes the [Bicep](/azure/azure-resource-manager/bicep) language. + +## Farmer + +For F# programmers, [Farmer](https://compositionalit.github.io/farmer/) is a free, open-source, community-driven technology providing an easy-to-learn library for rapidly authoring and deploying entire Azure architectures. Farmer generates [Azure Resource Manager (ARM)](/azure/azure-resource-manager) templates that define the infrastructure and configuration for your project. + +Farmer provides simple code snippets that allow you to rapidly construct complex topologies and idempotent deployments. Farmer is cross-platform and completely backwards compatible with ARM templates. Farmer generates standard ARM templates so you can continue to use existing deployment processes. + +## See also + +- [Azure Resource Manager](/azure/azure-resource-manager/) +- [Bicep](/azure/azure-resource-manager/bicep) +- [Farmer](https://compositionalit.github.io/farmer/) diff --git a/docs/fsharp/using-fsharp-on-azure/file-storage.md b/docs/fsharp/using-fsharp-on-azure/file-storage.md index d39f2df111252..6d00e656a2e53 100644 --- a/docs/fsharp/using-fsharp-on-azure/file-storage.md +++ b/docs/fsharp/using-fsharp-on-azure/file-storage.md @@ -155,5 +155,5 @@ For more information about Azure File Storage, see these links. - [Azure File Storage is now generally available](https://azure.microsoft.com/blog/azure-file-storage-now-generally-available/) - [Inside Azure File Storage](https://azure.microsoft.com/blog/inside-azure-file-storage/) -- [Introducing Microsoft Azure File Service](/archive/blogs/windowsazurestorage/introducing-microsoft-azure-file-service) -- [Persisting connections to Microsoft Azure Files](/archive/blogs/windowsazurestorage/persisting-connections-to-microsoft-azure-files) +- [Introducing Azure File Service](/archive/blogs/windowsazurestorage/introducing-microsoft-azure-file-service) +- [Persisting connections to Azure Files](/archive/blogs/windowsazurestorage/persisting-connections-to-microsoft-azure-files) diff --git a/docs/fsharp/using-fsharp-on-azure/index.md b/docs/fsharp/using-fsharp-on-azure/other-azure-services.md similarity index 52% rename from docs/fsharp/using-fsharp-on-azure/index.md rename to docs/fsharp/using-fsharp-on-azure/other-azure-services.md index 469bc97744426..70bdcc80fe0db 100644 --- a/docs/fsharp/using-fsharp-on-azure/index.md +++ b/docs/fsharp/using-fsharp-on-azure/other-azure-services.md @@ -1,16 +1,14 @@ --- -title: Using F# on Azure -description: Guide to using Azure services with F# +title: Using other Azure services with F# +description: Guide to using other Azure services with F# author: sylvanc -ms.date: 08/26/2021 +ms.date: 11/04/2021 ms.custom: "devx-track-fsharp" --- -# Using F\# on Azure +# Using other Azure services with F\# -F# is a superb language for cloud programming and is frequently used to write web applications, cloud services, cloud-hosted microservices, and for scalable data processing. - -In the following sections, you will find resources on how to use a range of Azure services with F#. +In the following sections, you will find resources on how to use a range of other Azure services with F#. > [!NOTE] > If a particular Azure service isn't in this documentation set, please consult either the Azure Functions or .NET documentation for that service. Some Azure services are language-independent and require no language-specific documentation and are not listed here. @@ -21,45 +19,6 @@ Azure supports a wide range of virtual machine (VM) configurations, see [Linux a To install F# on a virtual machine for execution, compilation and/or scripting see [Using F# on Linux](https://fsharp.org/use/linux) and [Using F# on Windows](https://fsharp.org/use/windows). -## Using Azure Functions with F\# - -[Azure Functions](https://azure.microsoft.com/services/functions/) is a solution for easily running small pieces of code, or "functions," in the cloud. You can write just the code you need for the problem at hand, without worrying about a whole application or the infrastructure to run it. Your functions are connected to events in Azure storage and other cloud-hosted resources. Data flows into your F# functions via function arguments. You can use your development language of choice, trusting Azure to scale as needed. - -Azure Functions support F# as a first-class language with efficient, reactive, scalable execution of F# code. See the [Azure Functions F# Developer Reference](/azure/azure-functions/functions-reference-fsharp) for reference documentation on how to use F# with Azure Functions. - -Other resources for using Azure Functions and F#: - -* [Scale Up Azure Functions in F# Using Suave](https://blog.tamizhvendan.in/blog/2016/09/19/scale-up-azure-functions-in-f-number-using-suave/) -* [How to create Azure function in F#](https://www.mnie.me/azurefunctions) -* [Using the Azure Type Provider with Azure Functions](https://compositional-it.com/blog/2017/08-30-using-the-azure-type-provider-with-azure-functions/index.html) - -## Using Azure Storage with F\# - -Azure Storage is a base layer of storage services for modern applications that rely on durability, availability, and scalability to meet the needs of customers. F# programs can interact directly with Azure storage services, using the techniques described in the following articles. - -* [Get started with Azure Blob Storage using F#](blob-storage.md) -* [Get started with Azure File Storage using F#](file-storage.md) -* [Get started with Azure Queue Storage using F#](queue-storage.md) -* [Get started with Azure Table Storage using F#](table-storage.md) - -Azure Storage can also be used in conjunction with Azure Functions through declarative configuration rather than explicit API calls. See [Azure Functions triggers and bindings for Azure Storage](/azure/azure-functions/functions-bindings-storage) which includes F# examples. - -## Using Azure App Service with F\# - -[Azure App Service](https://azure.microsoft.com/services/app-service/) is a cloud platform to build powerful web and mobile apps that connect to data anywhere, in the cloud or on-premises. - -* [F# Azure Web API example](https://github.com/fsprojects/azure-webapi-example) -* [Hosting F# in a web application on Azure](https://github.com/isaacabraham/fsharp-demonstrator) - -## Using Apache Spark with F\# on Azure HDInsight or Azure Databricks - -[Apache Spark for Azure HDInsight](/azure/hdinsight/spark/apache-spark-overview) is an open source processing framework that runs large-scale data analytics applications. [Azure Databricks](/azure/databricks/scenarios/what-is-azure-databricks) is an Apache Spark-based analytics platform optimized for the Microsoft Azure cloud services platform. Azure makes Apache Spark easy and cost effective to deploy. Develop your Spark application in F# using [.NET for Apache Spark](../../spark/what-is-apache-spark-dotnet.md), a set of .NET bindings for Apache Spark. - -* [.NET for Apache Spark F# samples](https://github.com/dotnet/spark/tree/main/examples/Microsoft.Spark.FSharp.Examples) -* [Install .NET Interactive Jupyter notebooks in Azure HDInsight](../../spark/how-to-guides/hdinsight-notebook-installation.md) -* [Submit Apache Spark jobs to Azure HDInsight](../../spark/how-to-guides/hdinsight-deploy-methods.md) -* [Submit Apache Spark jobs to Azure Databricks](../../spark/how-to-guides/databricks-deploy-methods.md) - ## Using Azure Cosmos DB with F\# [Azure Cosmos DB](https://azure.microsoft.com/services/cosmos-db) is a NoSQL service for highly available, globally distributed apps. @@ -78,6 +37,19 @@ Azure Event Hubs can be used with F# in two ways: 1. Through the creation of F# Azure Functions which are triggered by events. See [Azure Function triggers for Event Hubs](/azure/azure-functions/functions-bindings-event-hubs), or 2. By using the [.NET SDK for Azure](/azure/event-hubs/event-hubs-csharp-ephcs-getstarted). Note these examples are in C#. +## Using Azure Functions with F\# + +[Azure Functions](https://azure.microsoft.com/services/functions/) is a solution for easily running small pieces of code, or "functions," in the cloud. You can write just the code you need for the problem at hand, without worrying about a whole application or the infrastructure to run it. Your functions are connected to events in Azure storage and other cloud-hosted resources. Data flows into your F# functions via function arguments. You can use your development language of choice, trusting Azure to scale as needed. + +Azure Functions provide efficient, reactive, scalable execution of F# code. See the [Azure Functions F# Developer Reference](/azure/azure-functions/functions-reference-fsharp) for reference documentation on how to use F# with Azure Functions. + +## Using Azure App Service with F\# + +[Azure App Service](https://azure.microsoft.com/services/app-service/) is a cloud platform to build powerful web and mobile apps that connect to data anywhere, in the cloud or on-premises. + +* [F# Azure Web API example](https://github.com/fsprojects/azure-webapi-example) +* [Hosting F# in a web application on Azure](https://github.com/isaacabraham/fsharp-demonstrator) + ## Using Azure Notification Hubs with F\# [Azure Notification Hubs](/azure/notification-hubs/) are multiplatform, scaled-out push infrastructure that enable you to send mobile push notifications from any backend (in the cloud or on-premises) to any mobile platform. @@ -105,14 +77,6 @@ Timer triggers call functions based on a schedule, one time or recurring. Timers can be implemented in F# and hosted on Azure via an [Azure Function in F# with a Timer Trigger](/azure/azure-functions/functions-bindings-timer). -## Deploying and Managing Azure Resources with F\# Scripts - -Azure VMs may be programmatically deployed and managed from F# scripts by using the Microsoft.Azure.Management packages and APIs. For example, see [Get Started with the Management Libraries for .NET](/previous-versions/azure/dn722415(v=azure.100)) and [Using Azure Resource Manager](/azure/azure-resource-manager/resource-manager-deployment-model). - -Likewise, other Azure resources may also be deployed and managed from F# scripts using the same components. For example, you can create storage accounts, deploy Azure Cloud Services, create Azure Cosmos DB instances and manage Azure Notification Hubs programmatically from F# scripts. - -Using F# scripts to deploy and manage resources is not normally necessary. For example, Azure resources may also be deployed directly from JSON template descriptions, which can be parameterized. See [Azure Resource Manager Templates](/azure/azure-resource-manager/resource-manager-template-best-practices) including examples such as the [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/). - ## Other resources * [Full documentation on all Azure services](/azure/) diff --git a/docs/fsharp/using-fsharp-on-azure/queue-storage.md b/docs/fsharp/using-fsharp-on-azure/queue-storage.md index 197707383eae8..1b7ee702baf11 100644 --- a/docs/fsharp/using-fsharp-on-azure/queue-storage.md +++ b/docs/fsharp/using-fsharp-on-azure/queue-storage.md @@ -163,12 +163,8 @@ To delete a queue and all the messages contained in it, call the If you're migrating from the old libraries, they Base64-encoded messages by default, but the new libraries don't because it's more performant. For information on how to set up encoding, see . -## Next steps - -Now that you've learned the basics of Queue storage, follow these links to learn about more complex storage tasks. +## See also - [Azure Storage APIs for .NET](/dotnet/api/overview/azure/storage) -- [Azure Storage Type Provider](https://github.com/fsprojects/AzureStorageTypeProvider) -- [Azure Storage Team Blog](/archive/blogs/windowsazurestorage/) - [Configure Azure Storage connection strings](/azure/storage/common/storage-configure-connection-string) - [Azure Storage Services REST API Reference](/rest/api/storageservices/Azure-Storage-Services-REST-API-Reference) diff --git a/docs/fsharp/using-fsharp-on-azure/table-storage.md b/docs/fsharp/using-fsharp-on-azure/table-storage.md index 2058e8007e8bf..6691f2b2adff4 100644 --- a/docs/fsharp/using-fsharp-on-azure/table-storage.md +++ b/docs/fsharp/using-fsharp-on-azure/table-storage.md @@ -177,13 +177,8 @@ You can delete a table from a storage account. A table that has been deleted wil [!code-fsharp[TableStorage](../../../samples/snippets/fsharp/azure/table-storage.fsx#L165)] -## Next steps - -Now that you've learned the basics of Table storage, follow these links -to learn about more complex storage tasks and the Azure Cosmos DB Table API. +## See also - [Introduction to Azure Cosmos DB Table API](/azure/cosmos-db/table-introduction) - [Storage Client Library for .NET reference](/dotnet/api/overview/azure/storage) -- [Azure Storage Type Provider](https://fsprojects.github.io/AzureStorageTypeProvider/) -- [Azure Storage Team Blog](/archive/blogs/windowsazurestorage/) - [Configuring Connection Strings](/azure/storage/common/storage-configure-connection-string) diff --git a/docs/fsharp/what-is-fsharp.md b/docs/fsharp/what-is-fsharp.md index 506ec3555b091..314f95caeb8f3 100644 --- a/docs/fsharp/what-is-fsharp.md +++ b/docs/fsharp/what-is-fsharp.md @@ -1,7 +1,7 @@ --- title: What is F# description: Learn about what the F# programming language is and what F# programming is like. Learn about rich types, functions, and how they fit together. -ms.date: 07/24/2021 +ms.date: 11/04/2021 --- # What is F\# @@ -35,7 +35,7 @@ F# has numerous features, including: * Pattern matching * Async programming -A full set of features are documented in the [F# language reference](./language-reference/index.md). +A full set of features are documented in the [F# language guide](./language-reference/index.md). ## Rich data types diff --git a/docs/fsharp/whats-new/fsharp-45.md b/docs/fsharp/whats-new/fsharp-45.md index 9156e36a84bdf..33178607b874a 100644 --- a/docs/fsharp/whats-new/fsharp-45.md +++ b/docs/fsharp/whats-new/fsharp-45.md @@ -43,7 +43,7 @@ let stackSpan = Span(mem2, 100) safeSum(stackSpan) |> printfn "res = %d" ``` -An important aspect to this is that Span and other [byref-like structs](../language-reference/structures.md#byreflike-structs) have very rigid static analysis performed by the compiler that restrict their usage in ways you might find to be unexpected. This is the fundamental tradeoff between performance, expressiveness, and safety that is introduced in F# 4.5. +An important aspect to this is that Span and other [byref-like structs](../language-reference/structs.md#byreflike-structs) have very rigid static analysis performed by the compiler that restrict their usage in ways you might find to be unexpected. This is the fundamental tradeoff between performance, expressiveness, and safety that is introduced in F# 4.5. ## Revamped byrefs @@ -71,7 +71,7 @@ type S(count1: int, count2: int) = member x.Count2 = count2 ``` -This disallows you from declaring a mutable member in the struct and emits metadata that allows F# and C# to treat it as readonly when consumed from an assembly. To learn more, see [ReadOnly structs](../language-reference/structures.md#readonly-structs). +This disallows you from declaring a mutable member in the struct and emits metadata that allows F# and C# to treat it as readonly when consumed from an assembly. To learn more, see [ReadOnly structs](../language-reference/structs.md#readonly-structs). ## Void pointers diff --git a/docs/fsharp/whats-new/fsharp-50.md b/docs/fsharp/whats-new/fsharp-50.md index 40ab38c0f1dce..ac005e02e048c 100644 --- a/docs/fsharp/whats-new/fsharp-50.md +++ b/docs/fsharp/whats-new/fsharp-50.md @@ -1,7 +1,7 @@ --- title: What's new in F# 5 - F# Guide description: Get an overview of the new features available in F# 5. -ms.date: 11/06/2020 +ms.date: 11/04/2021 --- # What's new in F# 5 @@ -281,7 +281,7 @@ let inline negate x = -x <@ negate 1.0 @> |> eval ``` -The constraint generated by the `inline` function is retained in the code quotation. The `negate` function's quotated form can now be evaluated. +The constraint generated by the `inline` function is retained in the code quotation. The `negate` function's quoted form can now be evaluated. This feature implements [F# RFC FS-1071](https://github.com/fsharp/fslang-design/blob/master/FSharp-5.0/FS-1071-witness-passing-quotations.md). @@ -371,7 +371,7 @@ using System; namespace CSharp { - public interface MyDimasd + public interface MyDim { public int Z => 0; } diff --git a/docs/index.yml b/docs/index.yml index cd2fb35432229..89593b42d98cb 100644 --- a/docs/index.yml +++ b/docs/index.yml @@ -167,7 +167,7 @@ tools: imageSrc: https://docs.microsoft.com/media/logos/logo_Csharp.svg url: csharp/index.yml # Card - - title: "A functional programming language for .NET" + - title: "A simple language for succinct, robust, and performant code" imageSrc: https://docs.microsoft.com/media/logos/logo_Fsharp.svg url: fsharp/index.yml # Card @@ -198,6 +198,8 @@ additionalContent: text: ASP.NET MVC apps in Windows containers - url: /aspnet/core/blazor/ text: "Blazor: Interactive client-side web UI with .NET" + - url: fsharp/scenarios/web-development.md + text: Using F# for web development # Card - title: Mobile links: @@ -252,8 +254,8 @@ additionalContent: text: Azure services for .NET developers - url: ./azure/sdk/azure-sdk-for-dotnet.md text: Azure SDK for .NET - - url: fsharp/using-fsharp-on-azure/index.md - text: Use F# on Azure + - url: fsharp/using-fsharp-on-azure/deploying-and-managing.md + text: Deploying and Managing Azure Resources with F\# # Card - title: Machine learning and AI links: @@ -265,6 +267,8 @@ additionalContent: text: Azure machine learning - url: spark/index.yml text: .NET for Apache Spark + - url: fsharp/scenarios/machine-learning.md + text: Using F# for Machine Leaning # Card - title: Game development links: diff --git a/samples/snippets/fsharp/lang-ref-1/snippet104.fs b/samples/snippets/fsharp/lang-ref-1/snippet104.fs deleted file mode 100644 index ca78afcdc55f8..0000000000000 --- a/samples/snippets/fsharp/lang-ref-1/snippet104.fs +++ /dev/null @@ -1,5 +0,0 @@ -#light "off" -let g x = - begin - x + 1 - end \ No newline at end of file diff --git a/samples/snippets/fsharp/tour.fs b/samples/snippets/fsharp/tour.fs index f6476d11ddddb..321674b239b84 100644 --- a/samples/snippets/fsharp/tour.fs +++ b/samples/snippets/fsharp/tour.fs @@ -946,7 +946,7 @@ module ImplementingInterfaces = /// The FSharp.Core library defines a range of parallel processing functions. Here /// you use some functions for parallel processing over arrays. /// -/// To learn more, see: https://msdn.microsoft.com/visualfsharpdocs/conceptual/array.parallel-module-%5Bfsharp%5D +/// To learn more, see: https://fsharp.github.io/fsharp-core-docs/reference/fsharp-collections-arraymodule-parallel.html module ParallelArrayProgramming = /// First, an array of inputs. @@ -963,40 +963,4 @@ module ParallelArrayProgramming = |> Array.Parallel.map (fun x -> computeSomeFunction (x % 20)) // Next, print the results. - printfn $"Parallel computation results: {computeResults}" - - - -/// Events are a common idiom for .NET programming, especially with WinForms or WPF applications. -/// -/// To learn more, see: https://docs.microsoft.com/dotnet/fsharp/language-reference/members/events -module Events = - - /// First, create instance of Event object that consists of subscription point (event.Publish) and event trigger (event.Trigger). - let simpleEvent = new Event() - - // Next, add handler to the event. - simpleEvent.Publish.Add( - fun x -> printfn $"this is handler was added with Publish.Add: %d{x}") - - // Next, trigger the event. - simpleEvent.Trigger(5) - - // Next, create an instance of Event that follows standard .NET convention: (sender, EventArgs). - let eventForDelegateType = new Event() - - // Next, add a handler for this new event. - eventForDelegateType.Publish.AddHandler( - EventHandler(fun _ _ -> printfn "this is handler was added with Publish.AddHandler")) - - // Next, trigger this event (note that sender argument should be set). - eventForDelegateType.Trigger(null, EventArgs.Empty) - - - -//#if COMPILED -//module BoilerPlateForForm = -// [] -// do () -// do System.Windows.Forms.Application.Run() -//#endif + printfn $"Parallel computation results: {computeResults}" \ No newline at end of file