Content deleted Content added
→Functional programming: typo Tags: Mobile edit Mobile web edit |
Rescuing 2 sources and tagging 0 as dead.) #IABot (v2.0.9.5 |
||
(28 intermediate revisions by 14 users not shown) | |||
Line 5:
| name = F#
| logo = F Sharp logo.svg
|
| logo caption =
|
| family = [[ML (programming language)|ML]]: [[Caml]]: [[OCaml]]
| designer = [[Don Syme]], [[Microsoft Research]]
| developer = [[Microsoft]], [[F Sharp Software Foundation|The F# Software Foundation]]
| released = {{Start date and age|2005}}, version 1.0
| latest_release_version = {{wikidata|property|reference|edit| Q648619 |P348}}
|
| latest preview version =
| latest preview date =
| typing = [[Static typing|Static]], [[Strong and weak typing|strong]], [[Type inference|inferred]]
| implementations =
Line 22:
| influenced = [[C Sharp (programming language)|C#]],<ref>for async</ref> [[Elm (programming language)|Elm]], [[F* (programming language)|F*]], [[LiveScript (programming language)|LiveScript]]
| programming language =
| operating system = [[Cross-platform software|Cross-platform]]: [[.NET]] framework, [[Mono (software)|Mono]]
| license = [[MIT License|MIT]]<ref>{{cite web |url=https://github.com/fsharp/fsharp/blob/master/License.txt |title=F# Software Foundation's License |website=[[GitHub]] |date=14 October 2021}}</ref><ref>{{cite web |url=https://github.com/Microsoft/visualfsharp/blob/master/License.txt |title=Microsoft's F# License |website=[[GitHub]] |date=16 October 2021}}</ref>
| website = {{URL|https://fsharp.org/}}
{{URL|https://learn.microsoft.com/en-us/dotnet/fsharp}}
| wikibooks = F Sharp Programming
| file ext = .fs, .fsi, .fsx, .fsscript
}}
'''F#''' (pronounced '''F sharp''') is a [[General-purpose programming language|general-purpose]], [[High-level programming language|high-level]], [[Strong and weak typing|strongly typed]], [[Programming paradigm#Multi-paradigm|multi-paradigm]] [[programming language]] that encompasses [[functional programming|functional]], [[imperative programming|imperative]], and [[object-oriented programming]] methods. It is most often used as a [[Cross-platform software|cross-platform]] [[Common Language Infrastructure]] (CLI) language on [[.NET]], but can also generate [[JavaScript]]<ref name="js">{{cite web |url=http://fsharp.org/use/web-apps/ |title=Using F# for Web Applications |author=The F# Software Foundation |access-date=2020-07-30}}</ref> and [[graphics processing unit]] (GPU) code.<ref name="gpgpu">{{cite web |url=http://fsharp.org/use/gpu/ |archive-url=https://web.archive.org/web/20191225110926/http://fsharp.org/use/gpu/ |url-status=dead |archive-date=2019-12-25 |title=Using F# for GPU Programming |author=The F# Software Foundation |access-date=2019-12-25}}</ref>
F# is developed by the [[F Sharp Software Foundation|F# Software Foundation]],<ref name="fsharporg">{{cite web |url=http://fsharp.org |title=The F# Software Foundation |author=The F# Software Foundation |access-date=2012-11-24}}</ref> [[Microsoft]] and open contributors. An [[Open-source software|open source]], cross-platform compiler for F# is available from the F# Software Foundation.<ref name="fsharposg">{{cite web |url=https://fsharp.github.io/ |title=F# Compiler (open source edition) @ github |author=The F# Software Foundation |access-date=2012-11-24 |archive-date=2013-05-17 |archive-url=https://web.archive.org/web/20130517105109/http://fsharp.github.io/ |url-status=dead }}</ref> F# is a fully supported language in [[Microsoft Visual Studio|Visual Studio]]<ref>{{cite web |url=https://docs.microsoft.com/en-us/visualstudio/ide/fsharp-visual-studio |title=Develop with Visual F# in Visual Studio |access-date=2020-07-30}}</ref> and [[JetBrains#IDEs|JetBrains Rider]].<ref>{{cite web |url=https://www.jetbrains.com/help/rider/F_Sharp.html |title=F# |access-date=2020-07-30}}</ref> [[Plug-in (computing)|Plug-ins]] supporting F# exist for many widely used editors including [[Visual Studio Code]], [[Vim (text editor)|Vim]], and [[Emacs]].
F# is a member of the [[ML (programming language)|ML]] language family and originated as a [[.NET Framework]] implementation of a core of the programming language [[OCaml]].<ref name="historyMSR"/><ref name="ocamlOrigins"/> It has also been influenced by [[C Sharp (programming language)|C#]],
Line 39 ⟶ 41:
===Versions===
{| class="wikitable"
|-
! F#<br/>version
! Language specification
! Date
Line 48 ⟶ 49:
! [[Runtime system|Runtime]]
|-
|
|
| May 2005<ref>{{cite web|last=Syme|first=Don|title=F# 1.0.8 released|url=http://blogs.msdn.com/b/dsyme/archive/2005/05/21/420795.aspx|publisher=Microsoft|access-date=September 7, 2014}}</ref>
Line 54 ⟶ 55:
|[[.NET Framework|.NET]] 1.0 - 3.5
|-
|
| [http://fsharp.org/specs/language-spec/index.html#f-20 August 2010]
| April 2010<ref>{{cite web|last=Syme|first=Don|title=F# 2.0 released as part of Visual Studio 2010|url=http://blogs.msdn.com/b/dsyme/archive/2010/04/12/f-2-0-released-as-part-of-visual-studio-2010.aspx|publisher=Microsoft|access-date=September 7, 2014}}</ref>
Line 60 ⟶ 61:
|[[.NET Framework|.NET]] 2.0 - 4.0, [[Mono (software)|Mono]]
|-
|
| [http://fsharp.org/specs/language-spec/index.html#f-30 November 2012]
| August 2012<ref>{{cite web|last=Zander|first=Jason|title=Visual Studio 2012 and .NET Framework 4.5 released to the web|url=http://blogs.msdn.com/b/jasonz/archive/2012/08/15/visual-studio-2012-and-net-framework-4-5-released-to-the-web.aspx|publisher=Microsoft|access-date=September 7, 2014}}</ref>
Line 66 ⟶ 67:
|[[.NET Framework|.NET]] 2.0 - 4.5, [[Mono (software)|Mono]]
|-
|
| [http://fsharp.org/specs/language-spec/index.html#f-31 November 2013]
| October 2013<ref>{{cite web|title=Visual Studio 2013 released to web|date=17 October 2013 |url=http://blogs.msdn.com/b/visualstudio/archive/2013/10/17/visual-studio-2013-released-to-web.aspx|publisher=Microsoft|access-date=September 7, 2014}}</ref>
|[[Linux]], [[macOS]], [[Microsoft Windows|Windows]];<br/>[[JavaScript]],<ref name="js"/> [[Graphics processing unit|GPU]]<ref name="gpgpu"/>
|[[.NET Framework|.NET]] 2.0 - 4.5, [[Mono (software)|Mono]]
|-
|
| [http://fsharp.org/specs/language-spec/index.html#f-40 January 2016]
| July 2015<ref>{{cite web|title=Announcing the RTM of Visual F# 4.0|url=http://blogs.msdn.com/b/dotnet/archive/2015/07/20/announcing-the-rtm-of-visual-f-4-0.aspx|publisher=Microsoft|access-date=September 15, 2015}}</ref>
Line 78 ⟶ 79:
|<!-- [[.NET Framework|.NET]] 2.0 - 4.5, [[Mono (software)|Mono]] -->
|-
|
| [http://fsharp.org/specs/language-spec/index.html#f-41 May 2018]
|March 2017<ref>{{Cite news|url=https://blogs.msdn.microsoft.com/dotnet/2017/03/07/announcing-f-4-1-and-the-visual-f-tools-for-visual-studio-2017-2/|title=Announcing F# 4.1 and the Visual F# Tools for Visual Studio 2017|access-date=2017-03-08|language=en-US}}</ref>
Line 85 ⟶ 86:
|[[.NET Framework|.NET]] 3.5 - 4.6.2, [[.NET]], [[Mono (software)|Mono]]
|-
|
|
|August 2018<ref>{{cite web|title=Announcing F# 4.5|date=14 August 2018|url=https://blogs.msdn.microsoft.com/dotnet/2018/08/14/announcing-f-4-5/|publisher=Microsoft|access-date=August 14, 2018}}</ref>
Line 92 ⟶ 93:
| [[.NET Framework|.NET]] 4.5 - 4.7.2,<ref>{{Cite web|url=https://www.nuget.org/packages/FSharp.Core/4.5.0|title=FSharp.Core 4.5.0}}</ref> [[.NET]] Core SDK 2.1.400<ref>{{cite web|title=Download .NET Core 2.1 (Linux, macOS, and Windows)|url=https://dotnet.microsoft.com/download/dotnet/2.1|publisher=Microsoft|access-date=May 13, 2021}}</ref>
|-
|
|
|March 2019<ref>{{cite web|title=Announcing F# 4.6|date=29 March 2019|url=https://devblogs.microsoft.com/dotnet/announcing-f-4-6/|publisher=Microsoft|access-date=March 29, 2019}}</ref>
Line 99 ⟶ 100:
| [[.NET Framework|.NET]] 4.5 - 4.7.2,<ref>{{Cite web|url=https://www.nuget.org/packages/FSharp.Core/4.6.0|title=FSharp.Core 4.6.0}}</ref> [[.NET]] Core SDK 2.2.300<ref>{{cite web|title=Download .NET Core 2.2 (Linux, macOS, and Windows)|url=https://dotnet.microsoft.com/download/dotnet/2.2|publisher=Microsoft|access-date=May 13, 2021}}</ref>
|-
|
|
|September 2019<ref>{{cite web|title=Announcing F# 4.7|date=23 September 2019|url=https://devblogs.microsoft.com/dotnet/announcing-f-4-7/|publisher=Microsoft|access-date=September 23, 2019}}</ref>
Line 106 ⟶ 107:
| [[.NET Framework|.NET]] 4.5 - 4.8,<ref>{{Cite web|url=https://www.nuget.org/packages/FSharp.Core/4.7.0|title=FSharp.Core 4.7.0}}</ref> [[.NET]] Core SDK 3.0.100<ref>{{cite web|title=Download .NET Core 3.0 (Linux, macOS, and Windows)|url=https://dotnet.microsoft.com/download/dotnet/3.0|publisher=Microsoft|access-date=May 13, 2021}}</ref>
|-
|
|
|November 2020<ref name="blogs.msdn.microsoft.com2">{{Cite web|url=https://devblogs.microsoft.com/dotnet/announcing-f-5/|title=Announcing F# 5|date=November 10, 2020}}</ref>
Line 113 ⟶ 114:
| [[.NET]] SDK 5.0.100<ref>{{cite web|title=Download .NET 5.0 (Linux, macOS, and Windows)|url=https://dotnet.microsoft.com/download/dotnet/5.0|publisher=Microsoft|access-date=May 13, 2021}}</ref>
|-
|
|
|November 2021<ref>{{Cite web|url=https://devblogs.microsoft.com/dotnet/fsharp-6-is-officially-here/|title=F# 6 is officially here!|date=November 9, 2021}}</ref>
Line 119 ⟶ 120:
[[JavaScript]],<ref name="js"/> [[Graphics processing unit|GPU]]<ref name="gpgpu"/>
| [[.NET]] SDK 6.0.100<ref>{{cite web|title=Download .NET 6.0 (Linux, macOS, and Windows)|url=https://dotnet.microsoft.com/download/dotnet/6.0|publisher=Microsoft|access-date=November 14, 2021}}</ref>
|-
|
|
|November 2022<ref>{{Cite web|url=https://devblogs.microsoft.com/dotnet/announcing-fsharp-7/|title=Announcing F# 7|date=November 8, 2022}}</ref>
Line 127:
[[JavaScript]],<ref name="js"/> [[Graphics processing unit|GPU]]<ref name="gpgpu"/>
| [[.NET]] SDK 7.0.100<ref>{{cite web|title=Download .NET 7.0 (Linux, macOS, and Windows)|url=https://dotnet.microsoft.com/en-us/download/dotnet/7.0|publisher=Microsoft|access-date=November 8, 2022}}</ref>
|-
|
|
|November 2023<ref>{{Cite web|url=https://devblogs.microsoft.com/dotnet/announcing-fsharp-8/|title=Announcing F# 8|date=November 14, 2023}}</ref>
Line 135 ⟶ 134:
[[JavaScript]],<ref name="js"/> [[Graphics processing unit|GPU]]<ref name="gpgpu"/>
| [[.NET]] SDK 8.0.100<ref>{{cite web|title=Download .NET 8.0 (Linux, macOS, and Windows)|url=https://dotnet.microsoft.com/en-us/download/dotnet/8.0|publisher=Microsoft|access-date=November 14, 2023}}</ref>
|-
| 9.0
|
|November 2024<ref>{{Cite web|url=https://learn.microsoft.com/en-us/dotnet/fsharp/whats-new/fsharp-9|title=What's new in F# 9|date=November 12, 2024}}</ref>
|[[Linux]], [[macOS]], [[Microsoft Windows|Windows]],
[[JavaScript]],<ref name="js"/> [[Graphics processing unit|GPU]]<ref name="gpgpu"/>
| [[.NET]] SDK 9.0.0<ref>{{cite web|title=Download .NET 9.0 (Linux, macOS, and Windows)|url=https://dotnet.microsoft.com/en-us/download/dotnet/9.0|publisher=Microsoft|access-date=January 13, 2025}}</ref>
|}
Line 145 ⟶ 148:
Earlier versions of the F# language were designed by [[Microsoft]] and [[Microsoft Research]] using a closed development process.
F# was first included in Visual Studio in the [[
F# originates from Microsoft Research, Cambridge, UK. The language was originally designed and implemented by [[Don Syme]],<ref name="historyMSR">{{cite web |url=https://www.microsoft.com/en-us/research/project/f-at-microsoft-research/ |title=F# Historical Acknowledgements |website=[[Microsoft]]
Andrew Kennedy contributed to the design of
{| class="wikitable"
|+ Summary of versions
|-
! F#<br/>version
|-
!
|valign="top"|
* Functional programming
Line 170 ⟶ 174:
* Modules (no functors)
* Nested modules
* .NET
|-
!
|
* Active patterns
Line 187 ⟶ 191:
* Computation expressions
|-
!
|
* Type providers
Line 196 ⟶ 200:
* Provided units-of-measure
|-
!
|
* Named union type fields
Line 202 ⟶ 206:
* Type inference enhancements
|-
!
|
* Printf on unitized values
Line 216 ⟶ 220:
* Params dictionaries
|-
!
|
* Struct tuples which inter-operate with C# tuples
Line 230 ⟶ 234:
* Support for 'fixed'
|-
!
|
* Versioning alignment of binary, package, and language
Line 245 ⟶ 249:
* Enumeration cases emitted as public
|-
!
|
* Anonymous record types
|-
!
|
* Implicit yields
Line 257 ⟶ 261:
* Open static classes
|-
!
|
* FSharp.Core now targets netstandard2.0 only
Line 274 ⟶ 278:
* Improved compiler analysis for library authors
|-
!
|
* Tasks
Line 282 ⟶ 286:
* “as” patterns
* Indentation syntax revisions
*
*
* Implicit integer conversions
* First-class support for .NET-style implicit conversions
Line 291 ⟶ 295:
* InlineIfLambda optimizer directive
* Resumable code
*
* Map has Keys and Values
*
*
* Informational warnings for rarely used symbolic operators
|-
!
|
* Static abstract members support in interfaces
Line 312 ⟶ 316:
* Parallel type-checking and project-checking support (experimental, can be enabled via VS setting, or by tooling authors)
* Miscellaneous bugfixes and improvements.
|-
!
|
* _.Property shorthand for (fun x -> x.Property)
* Nested record field copy and update
* while! (while bang) feature <ref>{{Cite web |url=https://devblogs.microsoft.com/dotnet/simplifying-fsharp-computations-with-the-new-while-keyword/ |title=Simplifying F# computations with the new 'while!' keyword' |
* Extended string interpolation syntax
* Use and compose string literals for printf and related functions
* Arithmetic operators in literals
* Type constraint intersection syntax
* Extended fixed binding
* Easier [<Extension>] method definition
* Static members in interfaces
* Static let in discriminated unions, records, structs, and types without primary constructors
* try-with
* Recursive calls and yield! within exception handler
* Tail call attribute
* [<Struct>] unions can now have > 49 cases
* Strict indentation rules
* New diagnostics from the compiler
* Switches for compiler parallelization
|-
! 9.0<ref>{{Cite web|url=https://learn.microsoft.com/en-us/dotnet/fsharp/whats-new/fsharp-9|title=What's new in F# 9| date=12 November 2024}}</ref>
|
* Nullable reference types
* Discriminated union .Is* properties
* Partial active patterns can return bool instead of unit option
* Prefer extension methods to intrinsic properties when arguments are provided
* Empty-bodied computation expressions
* Hash directives are allowed to take non-string arguments
* Extended #help directive in fsi to show documentation in the REPL
* Allow #nowarn to support the FS prefix on error codes to disable warnings
* Warning about TailCall attribute on non-recursive functions or let-bound values
* Enforce attribute targets
* Updates to the standard library (FSharp.Core)
* Developer productivity improvements
* Performance improvements
* Improvements in tooling
|}
Line 378 ⟶ 394:
Age : int }
</syntaxhighlight>
Records can be created as {{code|lang=fsharp|code=let r = { Name="AB"; Age=42 } }}. The <code>with</code> keyword is used to create a copy of a record, as in {{code|lang=fsharp|code={ r with Name="CD" } }}, which creates a new record by copying <code>r</code> and changing the value of the <code>Name</code> field (assuming the record created in the last example was named <code>r</code>).
A [[tagged union|discriminated union]] type is a [[type-safe]] version of [[union (computer science)|C unions]]. For example,
Line 400 ⟶ 416:
forms a sequence of squares of numbers from 0 to 14 by filtering out numbers from the range of numbers from 0 to 25. Sequences are [[Generator (computer programming)|generators]] – values are generated on-demand (i.e., are [[lazy evaluation|lazily evaluated]]) – while lists and arrays are evaluated eagerly.
F# uses [[pattern matching]] to bind values to names. Pattern matching is also used when accessing discriminated unions – the union is value matched against pattern rules and a rule is selected when a match succeeds. F# also supports ''
F# supports a general syntax for defining compositional computations called ''{{visible anchor|computation expressions}}''. Sequence expressions, asynchronous computations and queries are particular kinds of computation expressions. Computation expressions are an implementation of the [[monad (functional programming)|monad]] pattern.<ref name="seq">{{cite web |url=http://blogs.msdn.com/dsyme/archive/2007/09/22/some-details-on-f-computation-expressions-aka-monadic-or-workflow-syntax.aspx |title=Some Details on F# Computation Expressions |access-date=2007-12-14}}</ref>
Line 422 ⟶ 438:
Like other [[Common Language Infrastructure]] (CLI) languages, F# can use CLI types through object-oriented programming.<ref name="overview"/> F# support for object-oriented programming in expressions includes:
* Dot-notation, e.g., {{code|lang=fsharp|code=x.Name}}
* Object expressions, e.g., {{ code|lang=fsharp| code={ new obj() with member x.ToString() = "hello" } }}
* Object construction, e.g., {{code|lang=fsharp|code=new Form()}}
* Type tests, e.g., {{code|lang=fsharp|code=x :? string}}
Line 512 ⟶ 528:
</syntaxhighlight>
===Metaprogramming===
F# allows some forms of syntax customizing via [[metaprogramming]] to support embedding custom [[___domain-specific language]]s within the F# language, particularly through computation expressions.<ref name="overview"/>
F# includes a feature for run-time meta-programming called quotations.<ref name="quotations">{{cite web |url=http://msdn.microsoft.com/en-us/library/dd233212.aspx |title=Code Quotations (F#) |access-date=2012-11-24}}</ref> A quotation expression evaluates to an abstract syntax tree representation of the F# expressions. Similarly, definitions labelled with the <code>[<ReflectedDefinition>]</code> attribute can also be accessed in their quotation form. F# quotations are used for various purposes including to compile F# code into [[JavaScript]]<ref name="js"/> and [[Graphics processing unit|GPU]]<ref name="gpgpu"/> code.
===Information-rich programming===
Line 538 ⟶ 554:
===Agent programming===
F# supports a variation of the [[Actor model|
<syntaxhighlight lang="fsharp">
Line 599 ⟶ 615:
The [https://safe-stack.github.io/ SAFE Stack] is an end-to-end F# stack to develop web applications. It uses [[ASP.NET Core]] on the server side and [https://fable.io Fable] on the client side.<ref>{{Cite web|url=http://fable.io/|title=Fable: JavaScript you can be proud of!|website=fable.io|access-date=2017-12-09}}</ref>
===Cross-platform app development===
F# can be used together with the [https://visualstudio.microsoft.com/xamarin/ Visual Studio Tools for Xamarin] to develop apps for [[iOS]] and [[Android (operating system)|Android]]. The [https://
=== Analytical programming ===
Line 787 ⟶ 803:
{{Wikibooks|F Sharp Programming}}
* {{Official website|https://fsharp.org/}} The F# Software Foundation
* [https://fsharp.github.io The F# Open Source Group at GitHub] {{Webarchive|url=https://web.archive.org/web/20130517105109/http://fsharp.github.io/ |date=2013-05-17 }}
* [https://fsharp.net/ The Visual F# Developer Center] {{Webarchive|url=https://web.archive.org/web/20081119161341/http://www.fsharp.net/ |date=2008-11-19}}
* [https://web.archive.org/web/20121130163443/http://www.tryfsharp.org/ Try F#, for learning F# in a web browser]
Line 793 ⟶ 809:
* [https://learn.microsoft.com/en-us/archive/blogs/fsharpteam/ The Visual F# team blog]
* [https://www.microsoft.com/en-us/research/project/f-at-microsoft-research/ The original Microsoft Research website for F#]
* [https://web.archive.org/web/20110715231625/http://www.ctocorner.com/fsharp/book/default.aspx The F# Survival Guide, Dec 2009 (Web-based book)]
* [http://fsharp.org/specs/language-spec/ The F# Language Specification]
Line 807 ⟶ 822:
[[Category:.NET programming languages]]
[[Category:Cross-platform free software]]
[[Category:High-level programming languages]]
[[Category:Functional languages]]
[[Category:Microsoft free software]]
Line 819 ⟶ 835:
[[Category:Software using the MIT license]]
[[Category:Statically typed programming languages]]
<!-- Hidden categories below -->
[[Category:Articles with example OCaml code]]<!-- Code example category family member nearest F#. -->
|