Questions tagged [f#]

F# is a succinct, expressive and efficient functional and object-oriented language for .NET which helps you write simple code to solve complex problems.

F# is an open source, functional-first programming language which empowers users and organizations to tackle complex computing problems with simple, maintainable and robust code. It is used in a wide range of application areas and is available across multiple platforms.

F# runs on Linux, Mac OS X, Windows as well as HTML5 and GPUs. F# is free to use and has an OSI-approved open-source license. F# is supported by industry leading companies providing professional tools, and by an active open source community.


The Learning F# page provides information about tutorials and books. To install and run F# on various platforms including Windows, Linux, Mac, HTML5 and others, visit the Using F# page. For more information, see also Getting Started with F#.

Formal F# language specifications can be found on the F# Software Foundation website:

For idiomatic coding conventions and styles, please read F# Component Design Guidelines.

To search for F# operators such as "?" (dynamic operator) in StackOverflow, you can use http://symbolhound.com/.

Free F# Programming Resources

Rosetta Code

If you are familiar with another programming language such as Java or C# and want to leverage that knowledge to understand how to do the same in a different language then Rosetta Code list many common programming tasks and the solutions in many different programming languages. Most task are done for F# but not all.

Lambda Calculus

Since F# is based on functional programming and functional programming is based on lambda calculus.

An Introduction To Functional Programming Through Lambda Calculus by Greg Michaelson

Functional Programming

Introduction to Functional Programming by John Harrison
The code is ML, but F# started from ML and the ML in the book can easily be converted to F#.

The Conception, Evolution, and Application of Functional Programming Languages by Paul Hudak Introduces many concepts of functional programming not found in imperative programming.

Chat Room

Stack Overflow F# Tutorial

  1. Data structures and collections
  2. List comprehension
  3. Tuples and records
  1. Discriminated unions
  2. Enumeration
  3. Pattern matching
  4. Recursion
  1. Type inference
  2. Type handling
  3. Error handling
  4. Namespaces and modules
  5. Classes and inheritance
  6. Active patterns
  7. Units of measure
  8. Generic numbers
  9. Computation expressions
  1. Asynchronous workflows
  1. F# Interactive
  1. Performance optimization
  1. F# vs. C#
  1. F# and other functional programming languages

Official Logo:

fsharp logo


16860 questions
419
votes
15 answers

Is functional GUI programming possible?

I've recently caught the FP bug (trying to learn Haskell), and I've been really impressed with what I've seen so far (first-class functions, lazy evaluation, and all the other goodies). I'm no expert yet, but I've already begun to find it easier to…
shosti
  • 7,332
  • 4
  • 37
  • 42
216
votes
9 answers

In what areas might the use of F# be more appropriate than C#?

Over the last few years F# has evolved into one of Microsoft's fully supported languages employing many ideas incubated in OCaml, ML and Haskell. Over the last several years C# has extended its general purpose features by introducing more and more…
Peter McG
  • 18,857
  • 8
  • 45
  • 53
146
votes
3 answers

Getting started with F#

How do I go about getting into F# programming? What are some good starter samples to learn the language, or learn about some of its advantages over other languages? What tools do I need (e.g. Windows, Visual Studio, ...)?
Brian
  • 117,631
  • 17
  • 236
  • 300
142
votes
5 answers

Difference between fold and reduce?

Trying to learn F# but got confused when trying to distinguish between fold and reduce. Fold seems to do the same thing but takes an extra parameter. Is there a legitimate reason for these two functions to exist or they are there to accommodate…
Wallace
  • 5,319
  • 4
  • 17
  • 9
135
votes
5 answers

What are the primary differences between Haskell and F#?

I've searched on the Internet for comparisons between F# and Haskell but haven't found anything really definitive. What are the primary differences and why would I want to choose one over the other?
ljs
  • 37,275
  • 36
  • 106
  • 124
132
votes
4 answers

F# changes to OCaml

F# is derived from OCaml, but what major items are missing or added? Specifically I'm curious as to whether the resources available for learning OCaml are also useful to someone who wants to learn F#.
Erik Forbes
  • 35,357
  • 27
  • 98
  • 122
131
votes
9 answers

How to create a sequence of integers in C#?

F# has sequences that allows to create sequences: seq { 0 .. 10 } Create sequence of numbers from 0 to 10. Is there something similar in C#?
Budda
  • 18,015
  • 33
  • 124
  • 206
128
votes
1 answer

Why is this F# code so slow?

A Levenshtein implementation in C# and F#. The C# version is 10 times faster for two strings of about 1500 chars. C#: 69 ms, F# 867 ms. Why? As far as I can tell, they do the exact same thing? Doesn't matter if it is a Release or a Debug build.…
Robert Jeppesen
  • 7,837
  • 3
  • 35
  • 50
119
votes
4 answers

Best approach for designing F# libraries for use from both F# and C#

I am trying to design a library in F#. The library should be friendly for use from both F# and C#. And this is where I'm stuck a little bit. I can make it F# friendly, or I can make it C# friendly, but the problem is how to make it friendly for…
Philip P.
  • 2,364
  • 2
  • 15
  • 16
116
votes
6 answers

Why are functions in OCaml/F# not recursive by default?

Why is it that functions in F# and OCaml (and possibly other languages) are not by default recursive? In other words, why did the language designers decide it was a good idea to explicitly make you type rec in a declaration like: let rec foo ... =…
nsantorello
  • 1,709
  • 3
  • 16
  • 18
114
votes
3 answers

Object initialization syntax

I'm just starting out with F# and I can't find the syntax to do object initialization like in C# 3. I.e. given this: public class Person { public DateTime BirthDate { get; set; } public string Name { get; set; } } how do I write the following…
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275
109
votes
10 answers

Haskell composition (.) vs F#'s pipe forward operator (|>)

In F#, use of the the pipe-forward operator, |>, is pretty common. However, in Haskell I've only ever seen function composition, (.), being used. I understand that they are related, but is there a language reason that pipe-forward isn't used in…
Ben Lings
  • 28,823
  • 13
  • 72
  • 81
108
votes
7 answers

F# development and unit testing?

I just got started with F#, which is my first functional language. I have been working quasi-exclusively with C#, and enjoy a lot how F# leads me to re-think how I write code. One aspect I find a bit disorienting is the change in the process of…
Mathias
  • 15,191
  • 9
  • 60
  • 92
104
votes
1 answer

MbUnit under Linux, used within an F# project?

I tried asking this on the gallio-users list, but the question failed to appear (Google Groups says the post was successful). I suppose the list might be moderated by someone who does not read his email very often :-) Seeing as SO has tags for both…
user1002059
  • 1,525
  • 1
  • 9
  • 19
103
votes
6 answers

How can I use functional programming in the real world?

Functional languages are good because they avoid bugs by eliminating state, but also because they can be easily parallelized automatically for you, without you having to worry about the thread count. As a Win32 developer though, can I use Haskell…
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
1
2 3
99 100