diff options
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] |