Questions tagged [f#-4.0]

F# 4.0 is the released version of the F# functional language for .NET in the VS2015 timeframe. This tag should be used for version specific questions and new features of F# 4.0.

F# 4.0 marks the first major-version release of the F# language and VS tools to include community contributions. Visual F# 4.0 was built in completely int he open by F# community developers, in partnership with the Visual F# team at Microsoft and represents the work of 38 contributors, of whom over 75% have no Microsoft affiliation. Language implementation has shifted to a fully open mode of engineering, and language delivery is shifting to be much more cross-platform and multi-editor. Language design is done in an open, collaborative way through fslang.uservoice.com.

This tag should be used for version specific questions and new features of F# 4.0.

F# 4.0 comes with a number of new language features including

  • constructors as first-class functions
  • simplified mutable/ref values
  • normalized collections API
  • Implicit quotation of method arguments
  • Extended preprocessor grammar
  • Rational exponents in units of measure
  • Inheritance from types with multiple generic interface instantiations
  • Non-nullable provided types
  • Extension properties in object initializers

  • As well as runtime optimizations of non-structural comparison operators

  • the addition of convenience APIs for converting between possibly-null .NET types and F# option types
  • new extension methods for System.Net.WebClient, allowing for easier usage of WebClient within F# async workflows.

RFCs implemented in F# 4.0

See also

16 questions
6
votes
1 answer

Representing a restricted type without using a class

In F# can I represent a restricted type without defining a class? Lets say I want to represent all the pairs of number where the first divides the second. in C# I could do: class PairDivides { int a {get;private set;} int b {get;private…
AK_
  • 7,981
  • 7
  • 46
  • 78
4
votes
1 answer

F# Connect SQLProvider with Postgres

I'm a beginner in both F# and the .Net world, I'm trying to make this F# script work: #r "./packages/SQLProvider/lib/netstandard2.0/FSharp.Data.SqlProvider.dll" #r "./packages/SQLProvider/lib/netstandard2.0/netstandard.dll" #r…
Aristu
  • 761
  • 3
  • 17
  • 30
4
votes
1 answer

How to force app.config to become exe.config

This is probably a bug, but I have 2 F# projects in my solution. One is a console app, the other is a test app (expecto test so technically also console). There are also 3 other C# projects in the solution. When ever I build my solution the…
WhiteleyJ
  • 1,393
  • 1
  • 22
  • 29
4
votes
1 answer

Adding an extension method to a record with unit of measure

Why does this work: type Money = { Amount : decimal } with member inline m.gotMoney : bool = m.Amount > 0M but this doesn't type MoneyUOM<[]'currency> = { Amount : decimal<'currency> } with member inline m.gotMoney :…
GregC
  • 7,737
  • 2
  • 53
  • 67
4
votes
2 answers

System.MissingMethodException : Method not found: 'FSharp.Data.HttpResponse

I have written ATs for my application in F# using Tickspec. I am using FSharp.Data.Http.Request and I am getting the following error: System.MissingMethodException : Method not found: 'FSharp.Data.HttpResponse …
Marta
  • 1,132
  • 1
  • 10
  • 26
4
votes
2 answers

How does F# infer types and tags from other modules?

Here is a minimal code example I use to explain my problem. The following code is organised in two files and compiles alright: DataStruct.fs module MyMod type XXX = { a: int } with static member GetNew = { a = -1 …
Friedrich Gretz
  • 535
  • 4
  • 14
4
votes
1 answer

How to conditionally inline members in F#, or switch off inlining in Debug builds altogether

I can't readily remember where I read it, but my understanding of inline was that it is "switched off" (except for statically resolving type constraints) during debug builds. But it isn't, a breakpoint on an inline member is never hit and stepping…
Abel
  • 56,041
  • 24
  • 146
  • 247
4
votes
2 answers

How do query expression joins depend on the order of keys?

In the documentation for query expressions, I found: Note that the order of the keys around the = sign in a join expression is significant. I can't, however, find any information about how exactly the order is significant, what difference it…
Johann Hibschman
  • 1,997
  • 1
  • 16
  • 17
3
votes
1 answer

Does f# 4.0 support .net 3.5?

Can I use 4.0 compiler to create .net 3.5 dll? Or the minimal .net version is 4.5? Also, could the latest version of FSharp.Core be used with .net 3.5?
ais
  • 2,514
  • 2
  • 17
  • 24
3
votes
1 answer

F# 4.0 with inheritance throwing FS0073 internal error: the mustinline value 'Foo' was not inferred to have a known value

I realize that this was asked before but I dare risk being closed as duplicate since the original question is three years old and we are two major F# versions further now. Update: I have reported this as a bug to the F# team, but I'm still curious…
Abel
  • 56,041
  • 24
  • 146
  • 247
2
votes
1 answer

#if - #else - #endif breaking F# Script

Using Visual Studio 2015 Update 3 and fsi.exe from F# v4.0 I' trying to run this script: //error.fsx #if INTERACTIVE let msg = "Interactive" #else let msg = "Not Interactive" #endif let add x y = x + y printfn "%d" (add 1 2) Output:…
Matt Klein
  • 7,856
  • 6
  • 45
  • 46
1
vote
2 answers

Reformatting list based on a condition in F#

I'm new to functional programming and am working on a project in F#. I've run a problem: I have a list of type string list list and I need to build separate lists based on the middle element of each string list. For…
is0
  • 117
  • 5
1
vote
1 answer

DFA minimization in F#

I'm completely new to functional programming and have elected to use F# for a project which entails the parsing and minimization of a DFA. I currently have my parser completed and am able to format each element of the DFA's tuple (states, alphabet,…
is0
  • 117
  • 5
0
votes
1 answer

In F# what is the difference between float[,] and float[][] and how do I initialise float[][]?

I've written a function in F# which which uses the KMeans (http://accord-framework.net/docs/html/T_Accord_MachineLearning_KMeans.htm). A function called compute requires float[][] but I've never seen that in F#. only float[,]. Example of code is…
Silent Fart
  • 111
  • 2
  • 13
0
votes
0 answers

Interfaces, generics and method overloading in F# and how to leverage its type inference

Background: I am trying to expand my existing logging framework, which is currently a wrapper of static non-thread-safe methods over printfn and friends. My design goals are: having a generic interface ILog and concrete classes like Dbg, Log, Trace.…
Abel
  • 56,041
  • 24
  • 146
  • 247
1
2