Поделиться через


Visual F#

F# is a programming language that provides support for functional programming in addition to traditional object-oriented and imperative (procedural) programming. The Visual F# product provides support for developing F# applications and extending other .NET Framework applications by using F# code. F# is a first-class member of the .NET Framework languages and retains a strong resemblance to the ML family of functional languages.

Multiple-Paradigm Language

F# supports functional programming constructs such as the following:

  • Functions as values, which enables flexible manipulation of functions. For more information, see Functions as First-Class Values (F#).

  • Function composition and pipelining, which enables you to combine functions together to create new functions and to simplify the coding of successive operations on data. For more information, see Functions (F#).

  • Type inference, which reduces the requirement to explicitly call out types without sacrificing type safety.

  • Automatic generalization, which promotes code reuse by making it easy to write code that works with a variety of different types without any additional effort.

  • Pattern matching support, which simplifies complex conditional code, and discriminated unions, which are optimized to be used with pattern matching.

  • Collection types for working with immutable data, including list and sequence types.

  • Lambda expressions, which are important to many functional programming constructs.

  • Partial application of function arguments, which enables you to create new functions implicitly from existing ones. For more information, see Functions (F#).

  • Code Quotations, a feature that enables you to manipulate F# expressions programmatically.

F# supports object-oriented programming and .NET Framework capabilities such as the following:

  • The .NET Framework object model, including objects that have properties, methods, and events; polymorphism or virtual functions; inheritance; and interfaces.

  • Data encapsulation, or separating the public interface of a type from the implementation.

  • Operator overloading that works well with generics and built-in primitive types.

  • Type extensions, which enable you to extend an existing type easily without the additional overhead work of creating a new derived type.

  • Object expressions, which enable you to define small objects implicitly in expressions as needed, instead of declaring a new type and instantiating an object.

  • Access to the .NET Framework and any managed code assembly.

  • Access to native code through platform invoke.

F# also supports all the common imperative programming constructs, such as branching and looping constructs.

F# Libraries

The Visual F# product also includes an F# library that has many useful functions and types. This includes APIs for collections such as lists, arrays, maps, sets, and sequences. The F# library also supports reflection, events, and formatted I/O.

In addition, the F# library includes support for asynchronous workflows to support parallel computations, and mechanisms for communicating among parallel workflows. For more information, see Asynchronous Workflows (F#), Control.Async Class (F#), and Control.MailboxProcessor<'Msg> Class (F#).

The main F# library is FSharp.Core.dll. Additional libraries are available in the F# PowerPack, which is available on the Microsoft F# Developer Center Web site.

Interactive Scripting

Visual F# provides an interactive window that is integrated into the Visual Studio development environment. This window enables you to enter F# code and have it immediately compiled and executed. This enables you to easily prototype code constructs and test your code while you write it. The interactive window runs the F# interactive tool, fsi.exe, which you can also run from the command line. This feature allows F# to be used as a scripting language. For more information, see F# Interactive (fsi.exe) Reference.

Integration with Visual Studio

F# is integrated with Visual Studio, and has support for the following:

Title

Description

Getting Started with F#

Provides information about getting started with the current release of Visual F#.

Visual F# Development Portal

A gateway to a wide variety of information about F#.

Using Visual Studio to Write F# Programs

Provides information about using F# in the Integrated Development Environment (IDE), including project settings and IntelliSense.

F# Language Reference

Provides reference information about the F# language, including information about keywords, symbols, and operators.

F# Core Library Reference

Provides reference information about the F# core library, FSharp.Core.dll.

F# Compiler (fsc.exe) Reference

Provides information about the F# compiler, fsc.exe, including information about compiler options.

F# Interactive (fsi.exe) Reference

Provides information about F# Interactive, fsi.exe, including information about command-line options and diagnostic messages that are specific to F# Interactive.

Samples and Walkthroughs (F#)

Provides links to F# samples and walkthroughs.

Real World Functional Programming

Provides information and guidance on using F# in a variety of applications. This content is authored by Tomas Petricek and Jon Skeet and is provided by Manning Publications, Co.

See Also

Other Resources

Visual Studio