@@ -294,6 +294,107 @@ steps:
294294 # Default: false
295295 post_qualify : false
296296
297+ # Automatically group imports based on their module names, with
298+ # a blank line separating each group. Groups are ordered in
299+ # alphabetical order.
300+ #
301+ # By default, this groups by the first part of each module's
302+ # name (Control.* will be grouped together, Data.*... etc), but
303+ # this can be configured with the group_patterns setting.
304+ #
305+ # When enabled, this rewrites existing blank lines and groups.
306+ #
307+ # - true: Group imports by the first part of the module name.
308+ #
309+ # > import Control.Applicative
310+ # > import Control.Monad
311+ # > import Control.Monad.MonadError
312+ # >
313+ # > import Data.Functor
314+ #
315+ # - false: Keep import groups as-is (still sorting and
316+ # formatting the imports within each group)
317+ #
318+ # > import Control.Monad
319+ # > import Data.Functor
320+ # >
321+ # > import Control.Applicative
322+ # > import Control.Monad.MonadError
323+ #
324+ # Default: false
325+ group_imports : false
326+
327+ # A list of rules specifying how to group modules and how to
328+ # order the groups.
329+ #
330+ # Each rule has a match field; the rule only applies to module
331+ # names matched by this pattern. Patterns are POSIX extended
332+ # regular expressions; see the documentation of Text.Regex.TDFA
333+ # for details:
334+ # https://hackage.haskell.org/package/regex-tdfa-1.3.1.2/docs/Text-Regex-TDFA.html
335+ #
336+ # Rules are processed in order, so only the *first* rule that
337+ # matches a specific module will apply. Any module names that do
338+ # not match a single rule will be put into a single group at the
339+ # end of the import block.
340+ #
341+ # Example: group MyApp modules first, with everything else in
342+ # one group at the end.
343+ #
344+ # group_rules:
345+ # - match: "^MyApp\\>"
346+ #
347+ # > import MyApp
348+ # > import MyApp.Foo
349+ # >
350+ # > import Control.Monad
351+ # > import MyApps
352+ # > import Test.MyApp
353+ #
354+ # A rule can also optionally have a sub_group pattern. Imports
355+ # that match the rule will be broken up into further groups by
356+ # the part of the module name matched by the sub_group pattern.
357+ #
358+ # Example: group MyApp modules first, then everything else
359+ # sub-grouped by the first part of the module name.
360+ #
361+ # group_rules:
362+ # - match: "^MyApp\\>"
363+ # - match: "."
364+ # sub_group: "^[^.]+"
365+ #
366+ # > import MyApp
367+ # > import MyApp.Foo
368+ # >
369+ # > import Control.Applicative
370+ # > import Control.Monad
371+ # >
372+ # > import Data.Map
373+ #
374+ # A pattern only needs to match part of the module name, which
375+ # could be in the middle. You can use ^pattern to anchor to the
376+ # beginning of the module name, pattern$ to anchor to the end
377+ # and ^pattern$ to force a full match. Example:
378+ #
379+ # - "Test\\." would match "Test.Foo" and "Foo.Test.Lib"
380+ # - "^Test\\." would match "Test.Foo" but not "Foo.Test.Lib"
381+ # - "\\.Test$" would match "Foo.Test" but not "Foo.Test.Lib"
382+ # - "^Test$" would *only* match "Test"
383+ #
384+ # You can use \\< and \\> to anchor against the beginning and
385+ # end of words, respectively. For example:
386+ #
387+ # - "^Test\\." would match "Test.Foo" but not "Test" or "Tests"
388+ # - "^Test\\>" would match "Test.Foo" and "Test", but not
389+ # "Tests"
390+ #
391+ # The default is a single rule that matches everything and
392+ # sub-groups based on the first component of the module name.
393+ #
394+ # Default: [{ "match" : ".*", "sub_group": "^[^.]+" }]
395+ group_rules :
396+ - match : " .*"
397+ sub_group : " ^[^.]+"
297398
298399 # Language pragmas
299400 - language_pragmas :
0 commit comments