Is your enhancement request related to a problem? Please describe.
No
Describe the solution you'd like
If I define:
fun :: Char -> Int
fun = w
main = print (fun 'c')
and add w as an argument of fun, HLS could possibly:
- Look up all direct references to fun, and if there are any
- Ask me for something to insert (default _w_fun_123948 which I could just press enter to confirm)
- Insert at the appropriate position, parenthesising or expanding lambdas as necessary
Actually resolving those _s is the programmer's job. Indirect references aren't a problem (they reference the direct references, and so on). It's almost never going to be valid to add the argument and not add something at all the use sites (it is possible with whacky class setups), and in some cases there are defaults (e.g. one parameter value corresponds to the prior behaviour).
In the same vein this could be extended further (whichever are the most useful:
- Data and type constructor parameters (including record fields). May need two suggestions for DataKinds (type and value if used in both ways). type parameters of terms (TypeApplications, TypeAbstractions)
- Removing/replacing entities (not parameters) - likewise you need to say what is added in its place elsewhere, and could reference the parameters in the replacement
Inlining synonyms or small functions is a special case of this
- Removing parameters (at use sites this just deletes expressions, you still need an insert but for inside the function)
- Adding (add -> _ cases) and removing data constructors (delete whole cases matching, replace for value uses).
I think it's fairly common in big projects to have to do these sorts of jobs so they could be useful (though admittedly it doesn't help you when a new version of a dependent package has done it, unless you can fake it with a local version temporarily).
Describe alternatives you've considered
Leave HLS as it is
Additional context
N/A
Is your enhancement request related to a problem? Please describe.
No
Describe the solution you'd like
If I define:
and add
was an argument offun, HLS could possibly:Actually resolving those _s is the programmer's job. Indirect references aren't a problem (they reference the direct references, and so on). It's almost never going to be valid to add the argument and not add something at all the use sites (it is possible with whacky class setups), and in some cases there are defaults (e.g. one parameter value corresponds to the prior behaviour).
In the same vein this could be extended further (whichever are the most useful:
Inlining synonyms or small functions is a special case of this
I think it's fairly common in big projects to have to do these sorts of jobs so they could be useful (though admittedly it doesn't help you when a new version of a dependent package has done it, unless you can fake it with a local version temporarily).
Describe alternatives you've considered
Leave HLS as it is
Additional context
N/A