zzarchive-VisualFSharpPowerTools icon indicating copy to clipboard operation
zzarchive-VisualFSharpPowerTools copied to clipboard

Add a menu item for generating sig files from implementation files

Open dungpa opened this issue 9 years ago • 8 comments
trafficstars

UserVoice request: http://vfpt.uservoice.com/forums/247560-general/suggestions/5818930-generate-fsi-file-from-fs-file

Proposal 1: Use signature generation from VFPT Pros:

  • Support XmlDoc comments
  • Support type constraints

Cons:

  • Only support pretty printing a single symbol at a time. Need to be rethought to support impl files, which may include multiple symbols at once.
  • Doesn't use layout combinators; so results may not look so nice.

Proposal 2: Use signature generation from FCS The idea is to expose signature generation, which has been used for generating signatures in FSI and --sig compiler option.

Pros:

  • Support layout configs
  • Results may be more precise

Cons:

  • Need some work in FCS to expose the API in a proper way
  • Will not support XmlDoc comments and type constraints out of the box.

dungpa avatar Dec 06 '15 11:12 dungpa

I need help to choose a proposal. It's not obvious which one is better at the moment.

dungpa avatar Dec 06 '15 11:12 dungpa

I think we should have both, signature generation from VFPT could be on a per function basis, generating the signature from an existing implementation, but it should also have scaffold generation from a declaration in the signature file. FCS generation can be for generating it for an entire source file, and in turn there should be scaffold generation for the entirety of an existing signature file.

cloudRoutine avatar Dec 06 '15 11:12 cloudRoutine

Maybe we could use YC.PrettyPrinter to improve the layout of the individual signature generation. Since it'd only be once function at a time it should be fast enough.

cloudRoutine avatar Dec 06 '15 11:12 cloudRoutine

I think we should document the whole flow(s) first.

vasily-kirichenko avatar Dec 06 '15 12:12 vasily-kirichenko

The idea is as follows:

  1. Right click on an F# file in Solution Explorer, click "Generate signature file for the implementation file"
  2. If the sig file exists, ask users to confirm overwriting the sig file. If users answer No, terminate here.
  3. Even if a sig file is there, we still generate everything from scratch.

Note that this only helps users in first-time generation of signature files. They have to maintain these files manually after that. It would be great if we can pick XmlDoc comments and put them into sig files since they supersede XmlDoc comments in impl files.

dungpa avatar Dec 06 '15 17:12 dungpa

My thoughts:

  • Generating/regenerating fsi files is not enough to push people to actually use signatures.
  • Advanced developers find signatures so valuable that lacking of any tool support does not stop them using signatures.
  • Conclusion: adding just initial generation does not help much for the rest of us, ordinary programmers. We should carefully reread Scott's paper on the topic and then discuss with him and others how exactly it should be implemented. I believe that the advantages of using signatures are huge, so I we should approach this task seriously.

/cc @swlaschin

vasily-kirichenko avatar Dec 12 '15 19:12 vasily-kirichenko

To be honest, my expectation is low on this matter. I hope to implement this feature so that we can use it on VFPT and make long-term maintenance of the project easier. Initial generation could ease some pains in introducing signature files to the project.

F# users aren't going to use it that easy even when advanced support is there; the main thing is that signature files are belittle and foreign in F# world.

dungpa avatar Dec 17 '15 22:12 dungpa

@dungpa @vasily-kirichenko Just to say I would use this feature! You are right that signature files are not widely used in F# - partly because they require tooling like this - but they are certainly an entirely reasonable part of F# methodology for those who use them.

dsyme avatar Jan 05 '16 21:01 dsyme