63 lines
1.0 KiB
Markdown
63 lines
1.0 KiB
Markdown
# sort-imports
|
|
|
|
Sort Haskell import statements
|
|
|
|
## Install
|
|
|
|
```bash
|
|
git clone https://github.com/evanrelf/sort-imports.git
|
|
cd sort-imports
|
|
stack install
|
|
```
|
|
|
|
## Usage
|
|
|
|
Takes input on `stdin` or with `--file 'path/to/file.hs'`, and outputs to `stdout`. For example:
|
|
|
|
```bash
|
|
sort-imports < input.hs > output.hs
|
|
```
|
|
|
|
`input.hs`:
|
|
|
|
```haskell
|
|
module Main where
|
|
|
|
import qualified ModuleC as C
|
|
import ModuleD ((>>=), function, Type(..))
|
|
import ModuleA
|
|
import ModuleB hiding (aaa, ccc, bbb)
|
|
|
|
import AnotherModuleB
|
|
import AnotherModuleC
|
|
import AnotherModuleA
|
|
|
|
main :: IO ()
|
|
main = putStrLn "Hello world"
|
|
```
|
|
|
|
`output.hs`:
|
|
|
|
```haskell
|
|
module Main where
|
|
|
|
import ModuleA
|
|
import ModuleB hiding (aaa, bbb, ccc)
|
|
import qualified ModuleC as C
|
|
import ModuleD (Type(..), function, (>>=))
|
|
|
|
import AnotherModuleA
|
|
import AnotherModuleB
|
|
import AnotherModuleC
|
|
|
|
main :: IO ()
|
|
main = putStrLn "Hello world"
|
|
```
|
|
|
|
Type `sort-imports --help` for more information.
|
|
|
|
## Editor integration
|
|
|
|
### Vim/Neovim
|
|
- [sbdchd/neoformat](https://github.com/sbdchd/neoformat)
|