Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Breaking Down Type Signatures in Tooltips #1203

Open
3 of 4 tasks
1eyewonder opened this issue Nov 14, 2023 · 4 comments
Open
3 of 4 tasks

Add Support for Breaking Down Type Signatures in Tooltips #1203

1eyewonder opened this issue Nov 14, 2023 · 4 comments

Comments

@1eyewonder
Copy link
Contributor

Details

Assuming we have the following code:

type GetNumberFromDb = IDbConnection -> int

let getNumberFromDb : GetNumberFromDb =
  fun conn -> 1

let addNumberFunc' (dbFunc : GetNumberFromDb) otherNumber conn =
  let number = dbFunc conn
  printfn "I got a number: %i" number
  number + otherNumber

type AddNumberFunc = int -> IDbConnection -> int

let addNumberFunc : AddNumberFunc =
  addNumberFunc' getNumberFromDb

let someHigherOrderFunction' (addNum : AddNumberFunc) num conn =
  addNum num conn
  // other logic here

type SomeHigherOrderFunction = int -> IDbConnection -> int

let someHigherOrderFunction : SomeHigherOrderFunction =
  someHigherOrderFunction' addNumberFunc

When hovering over function parameters with a type signature such as below
image

You can see the tooltip shows us the alias of the type signature (AddNumberFunc). I would like to propose we add the ability for navigating the type signatures further so you don't have to leave your current spot in the code to read and understand the signature.

Ideas/Suggestions:

  1. Create a 'mathetical proof' style signature. We'd have to account for type aliases for primitive types and other sorts of F# magic. Depending on the size of the 'proof' placing this under the 'Open the documentation' section may prove better. Maybe adding configuration of some sorts as well?
addNumberFunc : AddNumberFunc
addNumberFunc : int -> IDbConnection -> int

If this is found to be a reasonable idea/suggestion, I'd be willing to help contribute. I would just need guidance on areas of the codebase to search and refactor

Checklist

  • I have looked through existing issues to make sure that this feature has not been requested before
  • I have provided a descriptive title for this issue
  • I am aware that even valid feature requests may be rejected if they do not align with the project's goals
  • I or my company would be willing to contribute this feature
@TheAngryByrd
Copy link
Member

TheAngryByrd commented Nov 15, 2023

I agree this would be very nice to have but I think something like this should live in FSharp.Compiler.Service. If it's possible to prototype in FsAutocomplete, I'm for it but I get the feeling you'll hit some pain points and will have to push into FCS.

I also recall reading issues about this becoming extremely complicated as you can compound aliases:

type Fooer = string
type MyFoo = int -> int

type FooItAgain = MyFoo -> Task<Fooer>
type SlightlyDifferentFooIt = FooItAgain

I can't recall any direct issues about this from a quick search though.

@1eyewonder
Copy link
Contributor Author

Sounds good. I'll bring it up over there and see how plausible it is. I agree the compounding will be fun to say the least

@nojaf
Copy link
Contributor

nojaf commented Nov 16, 2023

Aren't tooltips in FSAC their own thing? I always thought you gents rolled your own thing for tooltips.

@TheAngryByrd
Copy link
Member

I think it's all the backing needed for it, like getting aliases of aliases and such. Like there's a bug about them: ionide/ionide-vscode-fsharp#1947

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants