Skip to content

siers/haskell-import-sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

- haskell-import-sort
    I use vim. I use haskell. I sort imports.
    ∴ I use vim to sort haskell imports.

- how?
    Well, through .vimrc I map the keybind \v:
        map <Leader>v vip!hs-import-sort<CR>:w<CR>

    through paramap, I concat paragraphs of text with null-bytes; demo here:
        https://gist.github.com/siers/01306a361c22f2de0122

    then in hs-import-sort I duplicate lines and disband them with newlines,
    which go through sed again, then get sorted.
    This makes `sort' ignore the "qualified" keyword. Yay.

- example
    $ cabal install process-extras string
    $ ghc paramap

    $ # This is from Yesod/Auth/OpenId.hs.
    $ hs-import-sort <<< "
    import Yesod.Form
    import Yesod.Core
    import Data.Text (Text, isPrefixOf)
    import qualified Yesod.Auth.Message as Msg
    import Control.Exception.Lifted (SomeException, try)
    import Data.Maybe (fromMaybe)
    import qualified Data.Text as T
    "
    import Control.Exception.Lifted (SomeException, try)
    import Data.Maybe (fromMaybe)
    import qualified Data.Text as T
    import Data.Text (Text, isPrefixOf)
    import qualified Yesod.Auth.Message as Msg
    import Yesod.Core
    import Yesod.Form

About

haskell import sorting script

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published