F# Language
This User Voice was for suggestions about the future evolution of the F# Language and Core Library.
- The new site is now at https://github.com/fsharp/fslang-suggestions!!!!
-
Better PR efforts: Write a client library to run F# code on the D-Wave quantum computers
Quantum computing attracts a lot of attention from scientists and software developers.
I suggest writing a client library to run F# code on the D-Wave quantum computers in order to improve F# visibility and popularity among software developers and scientists specializing in optimization, machine learning, pattern recognition and anomaly detection, financial analysis, software/hardware verification and validation, scheduling and logistics, bioinformatics.
The world's first commercial quantum computer (D-Wave One) was built in 2010 by the D-Wave Systems Inc. (offices in Palo Alto, CA, Washington, DC, and Burnaby, British Columbia, Canada). In 2013 the D-Wave Systems Inc. shipped a 512-qubit D-Wave Two…
2 votes -
Allow Object Expressions from abstract base classes without members
Object Expressions are a great feature to create instances of single-use interface / abstract class instances without polluting the namespace.
At the moment it is impossible to inherit from an abstract class which does not define any members.
If I have an abstract base class
[<AbstractClass>]
type Foo(i:int) = class endthen I would like to be able to exten it like this:
let foo = { new Foo(1) }
But this errors out with
Invalid object expression. Objects without overrides or interfaces should use the expression form 'new Type(args)' without braces.
The suggestion obviously doesn't work, since the…
4 votes -
3 votes
-
Provide Intellisense on 'tab' key when creating 'new' classes or types.
I would like to have the ability to hit the "tab key" when creating a new type with a constructor that will list the types available properties.
I C# this is done nicely with classes and as you assign a value the property is no longer available in intellisense when one tabs again to select another property.
1 vote -
Record copy update should be able change the generic type
type A<'a> =
{
mutable x: 'a
}let a = {x = 1}
{a with x="Hello"} // Type errorSince the x field is generic and F# is type safe, it would not be bad if the above was valid.
1 vote -
Allow fun arrows to start after a line break
As described here: https://github.com/Microsoft/visualfsharp/issues/1551
2 votes -
Allow static optimization conditionals
If we write the code as below, we will get a compile error: Static optimization conditionals are only for use within the F# library
let inline toBytes (x : ^a) : byte[] =
(^a : (static member ToBytes : ^a -> byte[])(x))
when ^a : byte = [|retype x : byte|]
when ^a : string = System.Text.Encoding.UTF8.GetBytes(retype x : string)
But allow "static optimization conditionals" is very useful, which allow us avoid to use those tricks like "Simple typeclass implementation". http://www.fssnip.net/9B3 votes -
Expand on cardinality functions Seq.exactlyOne, with Seq.tryExactlyOne and add oneOrMore, zeroOrMore
While it is quite trivial to write these functions, I think they have merit. First of, it is good there's a Seq.exactlyOne, but it throws and if you want a non-throwing version, you'll have to write one your own. It's odd there's a creator function, Seq.singleton, but not a test-function.
Since we have Seq.exactlyOne, it should have its logical cardinality counterparts for zero-or-one and one-or-more to be available too.
I suggest we add:
Seq.tryExactlyOne
Seq.oneOrMore (throws)
Seq.zeroOrMore (throws)
Seq.tryOneOrMore
Seq.tryZeroOrMoreThe reason it is better to have these in FSharp.Core is that, if one implements these by hand, it requires…
7 votes -
Allow type annotations at the top level in fsi
Currently, using a type annotation at the top level in fsi results in a syntax error:
> 1 : int;;
1 : int;;
--^stdin(1,3): error FS0010: Unexpected symbol ':' in interaction. Expected incomplete structured construct at or before this point, ';', ';;' or other token.
The workaround is to wrap the whole expression in parentheses, but I don't believe there's any reason for it to be necessary. It has misled some people into thinking they need to use another syntax instead (I've seen people try to use :?> for example).
6 votes -
Add ofObj to Seq and Array
The Option module defines Option.ofObj which converts a potential nullable value to an option.
Collections (Seq and array) can be null in interop scenarios, but it'd often be natural to interpret a null collection as an empty collection.
It's possible to compose such behaviour from existing building blocks, e.g. with Option.ofObj >> Option.toArray >> Array.concat
This seems like quite a roundabout way to do things, so I'd like to propose equivalent functions for Seq and Array:
// seq<'a> -> seq<'a>
Seq.ofObj// 'a [] -> 'a []
Array.ofObj6 votes -
Automate the need to explicitly write out generic parameter constraints in classes
Given that F# already automatically tells you what member constraints the classes should have, why not go an extra step and have the compiler write them out implicitly like in normal let statements.
I just recently had a situation where in a class I had to explicitly write a bunch of them all out like in the following:
```
type FFRec<'state when 'state: (member Tape: Stack<unit -> unit>)
and 'state: (member Mem: ObjectPool)
and 'state: (member Str: CudaStream)
and 'state: (member Workspace: Workspace)
and 'state: (member IsInferenceOnly: bool)> =
```
This would be bad if I had a bunch of…3 votes -
Impement auto notification
Impement auto notification chages for classes and records when implemented INotifyPropertyChanged or custom.
type A() =
let achaged name old new =
PropertyChanged(this, name)
member B : int 3 with get and set and notifyby achanged1 vote -
Implement interface delegating
Implement interface delegating by next syntax:
type MyType() =
let delegator : IAddingService
interface IAddingService by delegator with
member this.Add x y = // <- this is override
x + ySpecial behavior when event in interface - sender substitution
1 vote -
Allow lower-case DU cases when [<RequireQualifiedAccess>] is specified
Currently, it is not allowed to declare DU cases with lower-case letters. For instance, this is not allowed:
type Foo =
| foo
| bar
| baz
// etc...This yields: error FS0053: Discriminated union cases and exception labels must be uppercase identifiers
As I understand it, this is to prevent ambiguity in pattern matching between matching a union case and binding to an identifier. However, this is not an issue if the [<RequireQualifiedAccess>] attribute is specified on the DU. Therefore, I propose we allow lower-case cases in this case.
1 vote -
Relax indentation rules on Records
The current indentation rules around records seem inconsistent, or at least counter-intuitive. Consider for instance:
type Foo = {
....Foo:int
....}type Bar = {
....F:Foo
....}let bar = {
....F = {
........Foo = 10
........}
....}This is valid. But if you change F in Bar to VeryLongName:
type Baz = {
....VeryLongName:Foo
....}let baz = {
....VeryLongName = {
........Foo = 10
........}
....}We now get a warning:
warning FS0058: Possible incorrect indentation: this token is offside of context started at position (10:20). Try indenting this token further or using standard formatting conventions.In…
9 votes -
Literal sprintf
Allow:
```
[<Literal>]
let a = sprintf "%s" "string"
```16 votes -
Support isNull when querying the built-in SQL type providers
Right now the query expression-to-LINQ translation doesn't support queries such as `query { for x in table do where (isNull x.Field) }`. Instead we have to use `where (x.Field = null)`. That's quite inconsistent: in normal (non-query) code, `isNull` is advised, but in query code, we can't use it.
5 votes -
Have TypeProviderConfig.IsHostedExecution = true for type providers instantiated in *.fsx files
Have TypeProviderConfig.IsHostedExecution = true for type providers instantiated in *.fsx files
This came up in my work on FSharp.Data.SqlClient library.
Up until version 1.8.2 version of the library SqlCommandProvider provided command types with two constructors of following signatures:
new: connectionString: string, ?commandTimeout: int
new: ?connection: SqlConnection, ?transaction: SqlTransactoin, ?commandTimeout: int
Keep in mind that above are not normal F# type signatures but rather signature as suggested by Intellisense otherwise parameters with default values won’t show as optional.
It allowed to write following code:
do
use cmd = new SqlCommandProvider<"SELECT 42", "Server=.;Integrated Security=true">()
cmd.Execute()
It resolves to second constructor invocation where…7 votes -
Add a warning for new keyword used on types which are not IDisposable
This is an alternative to: https://fslang.uservoice.com/forums/245727-f-language/suggestions/15257796-remove-warning-for-new-keyword-on-idisposable
The idea is that the new keyword provides valuable information, but only if you do not use it on all types.
When avoiding its usage, you get a visual clue as to instances of disposable types, as well as warnings if you bind them.
By making it a warning to use new unnecessarily, the compiler would effectively enforce a "best practice" with regards to IDisposable usage. It goes a long way today, but requires discipline to make it useful.
This would be especially helpful to people coming to F# from C#, as many immediately…
21 votes -
allow compiler directive to switch off inlining
to get around debugging issues with the inline macro device, this pattern creaps into the code base (taken from FsPickler):
#if DEBUG
let writeBoundedSequence
#else
let inline writeBoundedSequence
#endifIt would be nice to be able to turn off the effect of the inline keyword for files and entire projects while compiling for debugging purposes. Also, optionally setting ignore inline for code executed in an interactive session would be useful too.
8 votes