play-haskell
play-haskell copied to clipboard
Button for running a code formatter
To make the playground double as a place for trying out different Haskell code formatters without having to download and build them all, it would be nice to have a UI element to run your code through one of a couple of high-profile code formatters (ormolu, brittany, stylish-haskell, maybe even configurable fourmolu?, others?). How exactly this UI element should look, I'm not sure. It definitely shouldn't take up a lot of space if you're not using it.
Some things to think about:
- If the formatter runs on the server (probably), doing a formatting operation should also count (a little bit) against your spam score. How much should depend on how long a formatter takes to process some file; hopefully this is not very long usually?
- We should verify for each formatter in question that they not have any risk of actually running part of the code being formatted (I'm thinking about too-clever handling of CPP or TH), because then that would be unsafe.
- It should hook into the undo/redo functionality of the Ace editor so that the user can undo the formatting easily.
How much should depend on how long a formatter takes to process some file; hopefully this is not very long usually?
It's usually fairly quick yes