Commit 48f84a9e by Zachary Snow

faster param type conversion

parent fc9999ae
...@@ -57,7 +57,7 @@ convert files = ...@@ -57,7 +57,7 @@ convert files =
explodeDescription other = [other] explodeDescription other = [other]
-- remove or rewrite source modules that are no longer needed -- remove or rewrite source modules that are no longer needed
files''' = map (uniq . concatMap replaceDefault) files'' files''' = map (\a -> concatMap (replaceDefault a) a) files''
(usageMapRaw, usedTypedModulesRaw) = (usageMapRaw, usedTypedModulesRaw) =
execWriter $ mapM (mapM collectUsageInfoM) files'' execWriter $ mapM (mapM collectUsageInfoM) files''
usageMap = Map.unionsWith Set.union $ map (uncurry Map.singleton) usageMap = Map.unionsWith Set.union $ map (uncurry Map.singleton)
...@@ -82,8 +82,8 @@ convert files = ...@@ -82,8 +82,8 @@ convert files =
then tell (Set.empty, Set.singleton m) then tell (Set.empty, Set.singleton m)
else tell (Set.singleton m, Set.empty) else tell (Set.singleton m, Set.empty)
collectModuleItemM _ = return () collectModuleItemM _ = return ()
replaceDefault :: Description -> [Description] replaceDefault :: [Description] -> Description -> [Description]
replaceDefault (part @ (Part _ _ _ _ name _ _)) = replaceDefault existing (part @ (Part _ _ _ _ name _ _)) =
if Map.notMember name info then if Map.notMember name info then
[part] [part]
else if Map.null maybeTypeMap then else if Map.null maybeTypeMap then
...@@ -93,6 +93,7 @@ convert files = ...@@ -93,6 +93,7 @@ convert files =
else if all isNothing maybeTypeMap then else if all isNothing maybeTypeMap then
[] []
else else
filter (not . flip elem existing) $
(:) (removeDefaultTypeParams part) $ (:) (removeDefaultTypeParams part) $
if isNothing typeMap if isNothing typeMap
then [] then []
...@@ -100,7 +101,7 @@ convert files = ...@@ -100,7 +101,7 @@ convert files =
where where
maybeTypeMap = snd $ info Map.! name maybeTypeMap = snd $ info Map.! name
typeMap = defaultInstance maybeTypeMap typeMap = defaultInstance maybeTypeMap
replaceDefault other = [other] replaceDefault _ other = [other]
removeDefaultTypeParams :: Description -> Description removeDefaultTypeParams :: Description -> Description
removeDefaultTypeParams (part @ Part{}) = removeDefaultTypeParams (part @ Part{}) =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment