Home

Feedback Request - F# Autocompletion

F# autocompletion for LINQPad is now underway with LINQPad 5, and I'd like feedback on the most important features to put into V1.

C# autocompletion currently includes the following features:

* Listings of accessible symbols when pressing Ctrl+Space (and sometimes automatic upon an alpha character)
* Expression-bound instance/static members of a type or object (usually automatic upon pressing '.')
* Parameter listings when making method calls or calling constructors, on Ctrl+Shift+Space or pressing ( or [
* Object initializer member listings
* Code-snippets (type the shortcut and press Tab to complete)
* Quick-info on mouse hover
* Smart tags to import assembly/namespace on an unbound symbol

As someone who thinks in C#, I'm aware of the peril of looking up the blub continuum, and I don't want to prioritize or design incorrectly!

What should I be aware of to (a) provide a good F# autocompletion experience, and (b) provide features in the right order?

I will be using the FSharp.Compiler.Service APIs.

Thanks!

Joe

Comments

  • I like the order you already have them in. as it is, I frequently have to quick swap the code into a C# mode just to see the correct naming/casing for something. Environment.what? Environment.GetFolderPath instead of environment.GetSpecialFolder. then Environment.GetFolderPath( SpecialFolder, or SpecialFolders.ProgX86 or ProgramFilesX86) .

    although Linqpad does frequently do a stand-up job of giving me intellisense/autocomplete, and parameter listings on code that's in the middle of a ton of F# while in C# mode, it doesn't always.

    sometimes I have to go comment out all the F# code or open a new tab to get some assistance in that area.
  • Cool plan, but I'm worried about one thing: FSharp.Compiler.Service is under Apache license while LinqPad is a commercial software.
  • edited April 2015
    @vaskir Where's the concern? IANAL but I usually consider anything non-GPL (MIT, Apache, etc) pretty safe.

    Is Apache not pretty much "do whatever, but be public about whatever changes you make to our software"?

    Also, really looking forward to this, @JoeAlbahari!
  • I would move the "Quick info on mouse hover" to the top 3. It is pretty useful, especially for newbies, to ensure F# compiler is agree with the programmer about function signature
  • agree with python, "Quick info on mouse hover" must be a top priority for the reason he mentioned about being able to quickly determine function signature. It's a key F# thing
  • About the license, ok :)

    Code snippets - I'm not sure they'd be useful at all.

    I suggest the following (prioritized) list:

    * Expression-bound instance/static members of a type or object (usually automatic upon pressing '.')
    * Parameter listings when making method calls or calling constructors, on Ctrl+Shift+Space or pressing ( or [
    * Listings of accessible symbols when pressing Ctrl+Space (and sometimes automatic upon an alpha character)
    * Quick-info on mouse hover
    * Smart tags to import assembly/namespace on an unbound symbol
    * Object initializer member listings
  • Like most others have suggested the function signature on mouse over is key for me.

    Really looking forwards to having LinqPad with decent F# support. It'll be awesome. Thanks for implementing this.
  • Please, add quick-info not only on mouse hover, but on some hotkey (ctrl-q will be fine) too for keyboad-centric guys.
  • As a mainly C# programmer, the thing that trips me up in coding F# is the more explicit casting and conversion rules. After typing up a lengthy F# sequence, I go to run, and there is some error where I do C# style casting which is difficult to track down and understand. While not 'autocomplete', contextual help with compile errors (e.g. highlighting the error after typing it) would really reduce my friction in coding F# more and in the same spirit of using the compiler output to live-assist coding.
  • Would auto-complete also be supported for Type Providers?
  • @marpstar it will be automatically since the implementation will use FSharp.Compiler.Service for everything. That package is used by all editors which seriously support F#.
  • Is there going to be a REPL loop with auto completion?
  • There's no plans for a REPL loop, although the domain will be preserved between queries as is currently the case. Do you see a benefit here? It would require a different editor, right?
  • I haven't really done much in terms of F#. I just think the REPL loop is pretty iconic of F# and I imagine there will be a lot of Typing->Mark The Line You Just Wrote->F5-> And repeat.
    With F#, expressions become both more prevalent and powerful. Since LINQPad already has its elegant way of displaying the result of a C# expression, I thought this was a logical next step for F5. Maybe you can use Ctrl-Enter to execute the current line (/multiline) and display in the output window?
    This is not experience talking, just speculating what would be the best of both worlds.
  • Might be more trouble than it's worth, but WRT a REPL, it seems like there are a couple of options supported in the service already?

    http://fsharp.github.io/FSharp.Compiler.Service/interactive.html

    The scenario I would love to see (if possible) is leveraging the debugger support along with F# interactive as a REPL. Specifically, including things like the 'locals' window.

    I like using REPL's, but they often (at least IME) mean you have to mentally keep track of what local variables you have and what each has a value of. This is where it seems like a LINQPad REPL could be a huge boost, where I'd be able to use a REPL but with a visual surface showing what local variables are present and what they're set to.

    At least for the F# case, it appears that you'd inspect a single dynamic assembly if you decided you were willing to surface the locals in a UI in such a REPL.

    http://stackoverflow.com/a/4998232/215534
    You can probably implement this using .NET Reflection - local variables and functions are defined as static properties/methods of types in a single dynamic assembly. You can get that assembly by calling GetExecutingAssembly (in FSI itself) and then browse the types to find all suitable properties.
  • An early beta is now available:

    http://www.linqpad.net/download.aspx#beta

    This includes the following features for F#:
    * Member listings on Ctrl+Space / period
    * Parameter listings on Shift+Ctrl+Space / open-parenthesis
    * Quick info on mouse hover

    Let me know of any problems you run into!
  • Just installed the beta. No intellisense. No params listing. No quick info.
  • There's a startup lag. Give it 5 seconds and it should come alive. I'm using FSharp.Compiler.Services, which has a JIT/warmup time.
  • edited December 2015
    I could ngen FSharp.Compiler.Services in the setup script. But this could require that automatic updates have administrative elevation.
  • The intellisense works for me, though the compiling seems pretty slow (with optimize on or off). And there are some edge cases, for example I got intellisense at [1..^10](^ being the cursor location)
  • edited December 2015
    So far for me F# is completely unusable, sadly.

    I'm having serious memory issues -- Linqpad process balloons up to 4.6GB+ usage after just a few minutes editing a query.

    I reference over 130 libraries within My Extensions that are all used regularly, and after removing all references, the F# query was responsive, but was still leaking memory slowly. Over the next 3-5 minutes, the process' usage increased from 300MB to 800MB with no user activity. Adding the references back caused LP to go unresponsive once again.

    I also tried enabling/disabling optimization as another test, but it had no effect.

    I don't have these kinds of issues with C# or VB, so I can only assume something's being done differently with the F# implementation. Thoughts?
  • edited December 2015
    I uploaded a newer beta last night (5.03.06) that should fix most of those problems. Can you let me know if there's a difference?
  • Now the compiling / executing is much faster.
  • Thanks Joe.

    It moves noticeably faster now, but after a few minutes, the memory usage still expands at a rapid pace. It now appears to rise fastest when I select a database connection. At that point, it jumps from around 500MB usage to around 1.2-1.5GB, then expands to 2-3GB.

  • Does the memory usage drop back down if you force a GC? (Shift+Alt+G)

    Or is it leaking?

    Can you give me a demo query that reproduces this memory usage?

    I can't get it to go much above 300MB before the GC kicks in and cleans up.
Sign In or Register to comment.