import-grouping

DescriptionRules for grouping import declarations
Options
  • legacy
  • preserve
  • single
  • by-qualified
  • by-scope
  • by-scope-then-qualified
Defaultlegacy
Ormolulegacy
SinceUnreleased

Some basic presets are provided but you can configure your own rules via a dedicated YAML configuration.

Predefined presets:

Predefined matchers:

Here's an example used in the custom configuration:

import-grouping:
  - name: "Text modules"
    rules:
      - glob: Data.Text
  - name: "The rest"
    rules:
      - match: all
        priority: 100
  - name: "My internals and monads unqualified"
    rules:
      - match: local-modules
        qualified: no
      - glob: Control.Monad
        qualified: no
  - name: "My internals and monads qualified"
    rules:
      - match: local-modules
        qualified: yes
      - glob: Control.Monad
        qualified: yes
  - name: "Specific monads"
    rules:
      - glob: Control.Monad.**

Examples

import Control.Monad (Monad (..))
import qualified Control.Monad.Error as Error
import Control.Monad.State.Lazy (MonadState (..))
import Data.Maybe (maybe)
import Data.Text (Text)
import qualified Data.Text
import Data.Text.IO (hGetLine)
import SomeInternal.Module1 (anotherDefinition, someDefinition)
import SomeInternal.Module1.SubModuleA
import qualified SomeInternal.Module2 as Mod2
import qualified System.IO as SIO
import Text.Printf (printf)
import Control.Monad (Monad (..))
import Control.Monad.State.Lazy (MonadState (..))
import Data.Maybe (maybe)
import Data.Text (Text)
import Data.Text.IO (hGetLine)
import SomeInternal.Module1 (anotherDefinition, someDefinition)
import SomeInternal.Module1.SubModuleA
import Text.Printf (printf)

import qualified Control.Monad.Error as Error
import qualified Data.Text
import qualified SomeInternal.Module2 as Mod2
import qualified System.IO as SIO
import Control.Monad (Monad (..))
import qualified Control.Monad.Error as Error
import Control.Monad.State.Lazy (MonadState (..))
import Data.Maybe (maybe)
import Data.Text (Text)
import qualified Data.Text
import Data.Text.IO (hGetLine)
import qualified System.IO as SIO
import Text.Printf (printf)

import SomeInternal.Module1 (anotherDefinition, someDefinition)
import SomeInternal.Module1.SubModuleA
import qualified SomeInternal.Module2 as Mod2
import Control.Monad (Monad (..))
import Control.Monad.State.Lazy (MonadState (..))
import Data.Maybe (maybe)
import Data.Text (Text)
import Data.Text.IO (hGetLine)
import Text.Printf (printf)

import qualified Control.Monad.Error as Error
import qualified Data.Text
import qualified System.IO as SIO

import SomeInternal.Module1 (anotherDefinition, someDefinition)
import SomeInternal.Module1.SubModuleA

import qualified SomeInternal.Module2 as Mod2
import Data.Text (Text)
import qualified Data.Text

import Data.Maybe (maybe)
import Data.Text.IO (hGetLine)
import qualified System.IO as SIO
import Text.Printf (printf)

import Control.Monad (Monad (..))
import SomeInternal.Module1 (anotherDefinition, someDefinition)
import SomeInternal.Module1.SubModuleA

import qualified SomeInternal.Module2 as Mod2

import qualified Control.Monad.Error as Error
import Control.Monad.State.Lazy (MonadState (..))

For more examples, see the test files.

See also