diff options
author | Ben Sima <ben@bsima.me> | 2023-08-22 17:15:50 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2023-09-19 20:49:54 -0400 |
commit | ffe3fd8a719be8d02b03bac6bc8232a7bc9fa692 (patch) | |
tree | 64aed59c9c6c22ae607c7379d2667cd71ef8d5d0 /Biz/Namespace.hs | |
parent | 2bab1000e2cbac69f3cd7d6c437eb63a63843b57 (diff) |
Lint faster by grouping files by extension
Previously I would lint every file individually, in serial. This took
forever. Now I group the files by extension (by first getting the Namespace) and
run each linter on all relevant files at once. This is so much faster its
stupid.
Also I added formatters back into the dev env because my editor needs them to
autoformat.
Diffstat (limited to 'Biz/Namespace.hs')
-rw-r--r-- | Biz/Namespace.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Biz/Namespace.hs b/Biz/Namespace.hs index 6d099fd..9621186 100644 --- a/Biz/Namespace.hs +++ b/Biz/Namespace.hs @@ -15,6 +15,7 @@ module Biz.Namespace toHaskellModule, toSchemeModule, isCab, + groupByExt, ) where @@ -24,6 +25,7 @@ import qualified Data.Aeson.Types as Aeson import qualified Data.Char as Char import qualified Data.List as List import qualified Data.List.Split as List +import qualified Data.Map as Map import qualified Data.Text as Text import qualified Text.Regex.Applicative as Regex @@ -134,3 +136,7 @@ reExt = isCab :: FilePath -> Bool isCab ('_' : _) = True isCab fp = "/_/" `List.isInfixOf` fp + +-- | Group a list of Namespaces keyed by their extensions +groupByExt :: [Namespace] -> Map Ext [Namespace] +groupByExt ns's = Map.fromListWith (++) [(ext ns, [ns]) | ns <- ns's] |