F# Language

This User Voice was for suggestions about the future evolution of the F# Language 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. Simulate higher-kinded polymorphism

    F# already has to make trade-offs when doing interop, e.g. it is possible to create a null value for a DU from C#, erased type providers don't work from anywhere but F# etc. Maybe F# could allow for higher-kinded polymorphism within F# code and use dynamic casts at runtime or maybe statically resolved inlining to simulate higher-kinded polymorphism.

    492 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…)
    • Syntax for turning properties into functions

      When we have F# records and classes (including the ones generated by type providers), we end up having to write things like this a lot:

      (fun x -> x.Name)

      It would be nice to have some shorthand for this, similar to what we can do with static members (but nicer than the Scala syntax please)

      457 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…)
      • Implement Syntactic Macros

        At least give it a try in a private branch, and upon success, enable them publicly with a compiler switch initially.

        453 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 for type classes or implicits

          (Updated the suggestion to "type classes or implicits", and edited it)

          Please add support for type classes or implicits.

          Currently, it's possible to hack type classes into F# using statically resolved type parameters and operators, but it is really ugly and not easily extensible.

          I'd like to see something similar to an interface declaration:

          class Mappable =
          abstract map : ('a -> 'b) -> 'm<'a> -> 'm<'b>

          Existing types could then be made instances of a type classes by writing them as type extensions:

          type Seq with
          class Mappable with
          member map = Seq.map

          type Option with
          class Mappable with …

          392 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 .NET Core and CoreCLR

            .NET Core is the new cloud runtime model for the CLR and used in ASP.NET vNext.

            377 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…)

              Strictly speaking this issue is not meant for https://fslang.uservoice.com, since it is about targeting a particular platform with the tooling, rather than the F# language or core library design itself.

              However, I’m leaving it open for now since it’s getting so many votes. We may close it sometime soon to release the votes.

              In any case, this work is planned by the Microsoft visualfsharp team and other contributors. Please contribute to the work at the http://github.com/Microsoft/visualfsharp repository and follow that repository for more details and updates.

              Relevant issues: https://github.com/Microsoft/visualfsharp/issues/387 and https://github.com/Microsoft/visualfsharp/pull/499

              Don Syme, F# Language and Core Library Evolution

            • Enable a compiler-warning when a recursive algorithm is not tail-recursive

              Add an TailRecursiveAttribute to enable a compiler-warning when a recursive algorithm is not tail-recursive. This should ideally also cover recursive seq { .. } and async { ... } expressions.

              311 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…)

                I am generally in favour of addressing this in F# 4.x+. I would want seq { .. } and async { … } tailcalls to also be addressed.

                A more detailed design is needed and some trialling would be great. Jack’s work is a great start. However, this is not an easy piece of work to do in a non-invasive way and my own experiments in this area have not yet led to something I feel confident to include in the F# language design.

                An implementation and testing would need to be provided by someone in the F# community (possibly including Microsoft or Microsoft Research, though not limited to them).

                Currently, initial implementations of approved language design can be submitted as pull requests to the appropriate branch of https://github.com/Microsoft/visualfsharp. See http://fsharp.github.io/2014/06/18/fsharp-contributions.html for info on how to contribute to the F# language/core library design

                I encourage you to consider continue…

              • Remove fun keyword from lambda expressions

                Maybe make it optional?
                Otherwise it is more verbose than C#.

                270 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…)
                • #package directive to import NuGet packages in F# interactive

                  It would be quite useful for F# interactive to support a #package directive to allow NuGet packages to be downloaded from within the REPL. I think it would be best if this directive simply downloaded the package, unpacked it, and automatically included (#I) the correct folder based on the framework version F# interactive is running under (e.g., net45). If a package doesn't include assemblies for the specific framework version F# interactive is using, we'd automatically include the folder for the latest framework version which is compatible; e.g., if running on .NET 4.5 and a package only includes a 'net40' folder,…

                  248 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 support for GADTs

                    Generalized Algebraic Data Types essentially extend standard union types to allow different generic instantiations when defined recursively.

                    You can see a simple explanation of how they work in haskell here: https://en.wikibooks.org/wiki/Haskell/GADT

                    They open the door to such fantastic type safe data structures as heterogeneous lists and so can vastly improve type safety within the language.

                    219 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 C#-like Anonymous Types in F#

                      Commonly I want to return some named values, or sequence of named values, in some expression. Currently I am forced to either go through the additional effort of defining a type, or use a tuple (with its associated error-proneness if there are multiple values of the same type). Anonymous record types would be very useful and would eliminate one of the areas of additional verbosity compared to C#.

                      215 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…)
                      • Override `ToString` for discriminated unions and records

                        It's a pain and dirty to add `override x.ToString() = sprintf "%A" x` to every type in order to make `String.Format()` happy:

                        type T1 =
                        { Id: int
                        Version: string }
                        override x.ToString() = sprintf "%A" x

                        type DU =
                        | C1 of int
                        | C2
                        override x.ToString() = sprintf "%A" x

                        I think it's very easy to teach the compiler generate this override automatically for all user types.

                        181 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 string interpolation to println syntax (from Swift)

                          The new language from Apple, Swift has a really nice syntax for println:
                          http://en.wikipedia.org/wiki/Swift_(programming_language)

                          let people = ["Anna": 67, "Beto": 8, "Jack": 33, "Sam": 25]
                          for (name, age) in people {
                          println("\(name) is \(age) years old.")
                          }

                          We could steal the idea but use % instead of \ for a better fit. It would also be compatible, and combinable (is that a word?) with existing printfn syntax:

                          let name = "Robert"
                          printfn "Hi %(name), your age is %d"
                          printfn : int -> string

                          Naturally there would be compiler errors if name does not exist.

                          179 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…)
                          • Implement first-class lensing / lenses in F#

                            When working with complex state structures, functional programming is, without a great deal of additional tooling (tooling that does not satisfactorily exist in F#), highly inconvenient, verbose, and even error-prone. These problems are so pronounced that many cite them as a reason to label functional programming itself as inapplicable to the domains within which complex state structures are inherent!

                            As functional programmers, we believe otherwise, and many even believe that it is in the domain of dealing with complex state artifacts that functional programming is especially beneficial and necessary! However, with such weak syntactic constructs such as these -

                            let…

                            168 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…)
                            • Provide covariance/contravariance language support with syntaxes in F# in sync with covariance/contravariance in C#/VB

                              Covariance/contravariance has its beginning in CLR 2.0 and also with the introduction of generics in .NET 2.0 (also in F#, C# and VB)

                              Then in C# 4.0 and VB 10, we have covariance/contravariance supports in the language itself. Currently we don't have support for these covariance and contravariance in F#.

                              I know it is a runtime feature of CLR 2.0 and 4.0 and I don't want to play catch up with C# and VB.

                              But this covariance/contravariance support in C# and VB are powerful to use and also have proven to provide cleaner and clearer ways to understand the code…

                              150 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 implementation of generic methods with constraints of the form 'T :> 'U

                                Currently this is solved as 'a = 'b.
                                This limitation does not exists in C# and it makes impossible to interact with some existing libraries, as in this case http://stackoverflow.com/questions/23643989/is-it-possible-to-implement-the-idbsett-interface-in-f
                                This will also allow to work around F#'s lack of generic (co/contra)-variance.

                                136 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 Implicit Interface Implementation

                                  F# only supports explicit interface implementation with the price of unnecessary and excessive casting (also causes readability issues), potential confusion when working with other languages, and causes limitation with F#'s OOP that could be resolved without any major language change.

                                  To expand on this, this post by Mauricio Scheffer describes the issue very well: http://bugsquash.blogspot.co.il/2009/01/implementing-interfaces-in-f.html

                                  In addition, I'm sure I could argue that people would prefer to just write `identifier.Member` rather than `(identifier :> Type).Member` whenever the member is a signature provided by an interface.
                                  This repeats quite a bit on average and it is messy, to say the least.

                                  133 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…)
                                  • Optional and named parameters on let bindings on modules

                                    Optional and named parameters are supported in static methods, but not in let bindings on modules. This many times forces you to use a static class instead of a module, which has some inconvenients. Ocaml has this, so I'm guessing is doable.

                                    131 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 NameOf operator to follow C#/VB update

                                      The Roslyn compiler currently (as of 2014-05-08) has a new NameOf operator listed as "Planned" for both C# and VB:
                                      (https://roslyn.codeplex.com/wikipage?title=Language%20Feature%20Status&referringTitle=Documentation)

                                      Pending its arrival there, it would be awesome to get something similar in F# as well.

                                      127 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…

                                        121 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 providers to generate types from other types

                                          There are occasions where it would be extremely useful to generate types from other types.

                                          As an example, F# interop with NHibernate is very clumsy simply because it's difficult to express types of the sort:

                                          // C# record class
                                          public class MyRecord
                                          {
                                          public virtual int Id { get; set; }
                                          public virtual string Description { get; set; }
                                          // etc...
                                          }

                                          It would be very compelling to be able to represent these as F# record types, but the CIL code generated for F# records is incompatible with NHibernate.

                                          Perhaps it could be possible, using a type provider, to generate…

                                          116 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…)

                                            Marking this as “approved in principle” per comment below.

                                            However it will be a difficult feature to land in practice and will be subject to very many caveats and likely limitations. There’s no certainty that this will make it into F#.

                                            We will open an RFC for it eventually (it won’t be fast :) )

                                            https://github.com/fsharp/FSharpLangDesign/tree/master/RFCs

                                            Don Syme
                                            F# Language Evolution

                                          ← Previous 1 3 4 5 9 10

                                          F# Language

                                          Feedback and Knowledge Base