F# Language

This User Voice is for suggestions about the future evolution of the F# Language and Core Library.

For discussions about tooling (editor support, compiler services etc.) please see http://fsharp.org/guides/engineering/issues.

The items “approved-in-principle” by for F# 4.x or beyond are listed at http://fslang.uservoice.com/forums/245727-f-language/status/1225914. You can contribute detailed designs, implementation and testing for these items. See http://fsharp.github.io/2014/06/18/fsharp-contributions.html for information on contributing to the evolution of the F# Language Design and Core Library.

I suggest we ...

You've used all your votes and won't be able to post a new idea, but you can still search and comment on existing ideas.

There are two ways to get more votes:

  • When an admin closes an idea you've voted on, you'll get your votes back from that idea.
  • You can remove your votes from an open idea you support.
  • To see ideas you have already voted on, select the "My feedback" filter and select "My open ideas".
(thinking…)

Enter your idea and we'll search to see if someone has already suggested it.

If a similar idea already exists, you can support and comment on it.

If it doesn't exist, you can post your idea so others can support it.

Enter your idea and we'll search to see if someone has already suggested it.

  1. 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.tryZeroOrMore

    The reason it is better to have these in FSharp.Core is that, if one implements these by hand, it requires…

    3 votes
    Vote
    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      You have left! (?) (thinking…)
    • 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).

      3 votes
      Vote
      Sign in
      Check!
      (thinking…)
      Reset
      or sign in with
      • facebook
      • google
        Password icon
        I agree to the terms of service
        Signed in as (Sign out)
        You have left! (?) (thinking…)
      • 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.ofObj

        6 votes
        Vote
        Sign in
        Check!
        (thinking…)
        Reset
        or sign in with
        • facebook
        • google
          Password icon
          I agree to the terms of service
          Signed in as (Sign out)
          You have left! (?) (thinking…)
          1 comment  ·  Admin →
        • 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
          Vote
          Sign in
          Check!
          (thinking…)
          Reset
          or sign in with
          • facebook
          • google
            Password icon
            I agree to the terms of service
            Signed in as (Sign out)
            You have left! (?) (thinking…)
          • 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 achanged

            1 vote
            Vote
            Sign in
            Check!
            (thinking…)
            Reset
            or sign in with
            • facebook
            • google
              Password icon
              I agree to the terms of service
              Signed in as (Sign out)
              You have left! (?) (thinking…)
            • 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 + y

              Special behavior when event in interface - sender substitution

              1 vote
              Vote
              Sign in
              Check!
              (thinking…)
              Reset
              or sign in with
              • facebook
              • google
                Password icon
                I agree to the terms of service
                Signed in as (Sign out)
                You have left! (?) (thinking…)
              • 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
                Vote
                Sign in
                Check!
                (thinking…)
                Reset
                or sign in with
                • facebook
                • google
                  Password icon
                  I agree to the terms of service
                  Signed in as (Sign out)
                  You have left! (?) (thinking…)
                • 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…

                  10 votes
                  Vote
                  Sign in
                  Check!
                  (thinking…)
                  Reset
                  or sign in with
                  • facebook
                  • google
                    Password icon
                    I agree to the terms of service
                    Signed in as (Sign out)
                    You have left! (?) (thinking…)
                  • Literal sprintf

                    Allow:
                    ```
                    [<Literal>]
                    let a = sprintf "%s" "string"
                    ```

                    13 votes
                    Vote
                    Sign in
                    Check!
                    (thinking…)
                    Reset
                    or sign in with
                    • facebook
                    • google
                      Password icon
                      I agree to the terms of service
                      Signed in as (Sign out)
                      You have left! (?) (thinking…)
                    • 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
                      Vote
                      Sign in
                      Check!
                      (thinking…)
                      Reset
                      or sign in with
                      • facebook
                      • google
                        Password icon
                        I agree to the terms of service
                        Signed in as (Sign out)
                        You have left! (?) (thinking…)
                        1 comment  ·  Admin →
                      • 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
                        Vote
                        Sign in
                        Check!
                        (thinking…)
                        Reset
                        or sign in with
                        • facebook
                        • google
                          Password icon
                          I agree to the terms of service
                          Signed in as (Sign out)
                          You have left! (?) (thinking…)
                        • 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…

                          18 votes
                          Vote
                          Sign in
                          Check!
                          (thinking…)
                          Reset
                          or sign in with
                          • facebook
                          • google
                            Password icon
                            I agree to the terms of service
                            Signed in as (Sign out)
                            You have left! (?) (thinking…)
                          • 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
                            #endif

                            It 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
                            Vote
                            Sign in
                            Check!
                            (thinking…)
                            Reset
                            or sign in with
                            • facebook
                            • google
                              Password icon
                              I agree to the terms of service
                              Signed in as (Sign out)
                              You have left! (?) (thinking…)
                              1 comment  ·  Admin →
                            • Remove warning for new keyword on IDisposable

                              The only time I ever use the new keyword is on Disposables, and even then only to silence the compiler warnings. I'm not sure what purpose the warning serves either, because you can still forget to bind the disposable with the use keyword instead of with let. What's more annoying is that it prevents you from effective pipelining.

                              Could this be removed from the next F# release, or perhaps replaced with a warning if you bind a Disposable with let instead of use?

                              5 votes
                              Vote
                              Sign in
                              Check!
                              (thinking…)
                              Reset
                              or sign in with
                              • facebook
                              • google
                                Password icon
                                I agree to the terms of service
                                Signed in as (Sign out)
                                You have left! (?) (thinking…)
                              • Return untyped syntax tree from ITypeProvider

                                Add the ability to *opt in* to send back an untyped syntax tree from ITypeProviders. The current type provider mechanism is good for simple data exploration use cases, but otherwise extremely limited, and will soon allow for less metaprogramming than Roslyn in some ways. Currently, some types of type providers not possible to create, because unbound generics, records, discriminated unions, and other normal language features are not supported.

                                With the ability to opt in to just returning an untyped syntax tree, it would enable the creation of just about any type provider. It would also effectively give F# macros, though…

                                27 votes
                                Vote
                                Sign in
                                Check!
                                (thinking…)
                                Reset
                                or sign in with
                                • facebook
                                • google
                                  Password icon
                                  I agree to the terms of service
                                  Signed in as (Sign out)
                                  You have left! (?) (thinking…)
                                • Multi-case unions compiled to struct

                                  I am posting this idea to be able to track its status since it is already informally under consideration. Tuples, records, and single-cases unions are have already planned (implementation even nearing completoin) to be compilable to a struct:

                                  struct tuples: https://fslang.uservoice.com/forums/245727-f-language/suggestions/6148669-add-support-for-structtuple
                                  struct records: https://fslang.uservoice.com/forums/245727-f-language/suggestions/6547517-record-types-can-be-marked-with-the-struct-attribu
                                  struct single-case unions: https://fslang.uservoice.com/forums/245727-f-language/suggestions/6147144-allow-single-case-unions-to-be-compiled-as-structs

                                  There is also already a proof of concept for unions of "blittable" types: https://fslang.uservoice.com/forums/245727-f-language/suggestions/7072844-utilise-clr-union-types-for-discriminated-unions

                                  There has also been a lot of discussion on the implementation of multi-case unions in the discussion of struct records: https://github.com/Microsoft/visualfsharp/pull/620

                                  One great use of multi-case unions compiled to struct would be optional computations (e.g. Option<'T>) for value…

                                  20 votes
                                  Vote
                                  Sign in
                                  Check!
                                  (thinking…)
                                  Reset
                                  or sign in with
                                  • facebook
                                  • google
                                    Password icon
                                    I agree to the terms of service
                                    Signed in as (Sign out)
                                    You have left! (?) (thinking…)
                                  • Nominal subtyping of unions

                                    This is basically a repost of "subtyping for discriminated unions" (https://fslang.uservoice.com/forums/245727-f-language/suggestions/6672490-subtyping-for-discriminated-unions), but with more details and a description of a concrete use case.

                                    I am reposting because I would like more discussion on this and because I think that declined requests are no longer tracked by Don Syme (and others).

                                    Don Syme declined the feature because he likes features to be generic and symmetric for types in F#. This is a good general rule and I trust in Don's good taste, but I think that this feature request is an exception to the rule, so the decline should…

                                    8 votes
                                    Vote
                                    Sign in
                                    Check!
                                    (thinking…)
                                    Reset
                                    or sign in with
                                    • facebook
                                    • google
                                      Password icon
                                      I agree to the terms of service
                                      Signed in as (Sign out)
                                      You have left! (?) (thinking…)
                                    • Support constant values in Discriminated unions

                                      Hi,

                                      While trying to model a music domain I ended up with this code:

                                      type Note = | C | CSharp | DFlat | D | DSharp | EFlat | E | F | FSharp
                                      | GFlat | G | GSharp | AFlat | A | ASharp | BFlat | B

                                      let noteName note =
                                      match note with
                                      | C -> "C" | CSharp -> "C#" | DFlat -> "Db" | D -> "D"
                                      | DSharp -> "D#" | EFlat -> "Eb" | E -> "E" | F -> "F"
                                      | FSharp -> "F#" | GFlat -> "Gb" | G…

                                      5 votes
                                      Vote
                                      Sign in
                                      Check!
                                      (thinking…)
                                      Reset
                                      or sign in with
                                      • facebook
                                      • google
                                        Password icon
                                        I agree to the terms of service
                                        Signed in as (Sign out)
                                        You have left! (?) (thinking…)
                                      • Support mixed F# and C# projects in order to extend F# usage

                                        Support mixing F# and C# source files in the same project in order to support a gradual move to F# for new users/organisations and to support cases where tooling is oriented at C# (F# not supported)

                                        For instance I could use this feature to slowly move a C# project to F# one class at the time. Another example would be to use C# tooling to generate web infrastructure like ASP.NET 5 controllers (because F# does not currently have templates for this) and then call directly into F# from those.

                                        P.S. Other languages that F# compares to like Scala already supported…

                                        113 votes
                                        Vote
                                        Sign in
                                        Check!
                                        (thinking…)
                                        Reset
                                        or sign in with
                                        • facebook
                                        • google
                                          Password icon
                                          I agree to the terms of service
                                          Signed in as (Sign out)
                                          You have left! (?) (thinking…)
                                        • kprintf with delayed string construction

                                          Currently kprintf and friends take in a continuation function and a StringFormat and return a curried function that when applied builds the string.

                                          It would be nice for logging frameworks to have an overload where the continuation does not build the string rather provides a delayed function to build the string.

                                          That way I can do something like:
                                          let public logWithFormat logLevel logFormat =
                                          kprintf (fun stringBuilder -> if logLevel > currentLoggingLevel then sprintf "%s" (stringBuilder())) logFormat

                                          10 votes
                                          Vote
                                          Sign in
                                          Check!
                                          (thinking…)
                                          Reset
                                          or sign in with
                                          • facebook
                                          • google
                                            Password icon
                                            I agree to the terms of service
                                            Signed in as (Sign out)
                                            You have left! (?) (thinking…)
                                          ← Previous 1 3 4 5 9 10
                                          • Don't see your idea?

                                          F# Language

                                          Feedback and Knowledge Base