-
Notifications
You must be signed in to change notification settings - Fork 155
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
Improve F# signature formatting #106
Comments
Nice one. It might be a good idea to follow what has been done in FSharpBinding. |
👍 |
This looks really interesting. +1 |
@dungpa The F# binding needs this addressing too I think it would be fairly easy to format like the above when the line length exceeds I could possibly look at a PR for this at some point if its of interest ... |
It would look nice using the proposed format above. This proposal also benefits FSharp.Compiler.Service API docs where there are lots of long type signatures. +1 |
Also will be really nice to colorize signature tip. I think it will be much easier to read. |
I built something to format long tips (over 80 characters) to break on so
Would be rendered like:
a tuple version is much the same:
|
I personally think it is better to show signatures via a sample use, e.g. something like this:
with hover-over or button to show alternative views, e.g. hover-over parameters can give docs and types. It is much less daunting (especially for curried functions) and in practice conveys much the same information. Cheers p.s. In some far-flung future version of F# we could even consider allowing an alternative signature signature something like this. I believe it's the right direction to give a more intuitive, readable signature syntax. For F# code, the focus is so much on expressions rather than types, that showing a signature by using expression syntax where possible (though there must of course be enough information to define the types). But that's all a separate conversation, and far off. |
Im not sure I understand, you would prefer a smaller example to demonstrate? val ratherlongfunction2 : a:int -> b:int -> c:int -> d:int -> e:int -> f:int
-> g:int -> h:int -> int In the example above the original signature would be: val ratherlongfunction2 : a:int -> b:int -> c:int -> d:int -> e:int -> f:int -> g:int -> h:int -> i:int -> j:int -> k:int -> l:int ->
m:int -> n:int -> o:int -> p:int -> q:int -> r:int -> s:int -> t:int -> u:int -> v:int -> w:int -> x:int -> y:int -> z:int -> int I think that even indenting to the start of the definition makes this clearer. Its beyond the scope of a simple change to add colouring, or adding alternative views etc. Although valid I would rather spend some time elsewhere, plus I would have to spend a lot more time immersed in the code, possibly adding to the DSL that currently describes tooltips. |
I agree the current tips quite a bit of concentration to use at times, the monodevelop tooltip shown above is an example of something quite difficult to read. Some of the issues in monodevelop is that the current code assumes only the first line will be the tooltip and everything else is a summary document, thats why the signature spills over. |
As an aside, a double popup tooltip could achieve contextual highlighting: pop up a tooltip with type information omitted: val ratherlongfunction2 : a -> b -> c -> d -> e -> f -> g -> h -> int and when you hover on the
|
In any case, I think this would be best done in F# Compiler Services - that way, other consumers (including Xamarin studio and F# Formatting) can benefit from a single implementation? |
Well I can certainly send the PR to compiler services instead, I would of thought FSharp.Formatting would of been the place for formatting though. |
Does the F.C.S expose the data for tool tips in some nice discriminated union, or as a plain string? If it is a DU, then we can certainly format it nicely. Otherwise, I'd wait until we can get data in a nicer format. |
This is what I did for the language service in the XS addin: |
This is fixed for now |
Take the following signature:
Once it gets to a certain width it becomes hard to read especially if it is forced to break lines in the middle. Perhaps some formatting like this might be nice:
colourising type names and the
->
could also improve legibilityThe text was updated successfully, but these errors were encountered: