git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Add missing cases to usedModules
cfb5c0cGary Burgess
src/Language/PureScript/ModuleDependencies.hs+6−4
@@ -23,7 +23,7 @@ import Control.Monad.Error.Class (MonadError(..))
23
23
24import Data.Graph
24import Data.Graph
25import Data.List (nub)
25import Data.List (nub)
26−import Data.Maybe (fromMaybe, mapMaybe)
26+import Data.Maybe (fromMaybe)
27
27
28import Language.PureScript.Crash
28import Language.PureScript.Crash
29import Language.PureScript.AST
29import Language.PureScript.AST
@@ -54,22 +54,24 @@ sortModules ms = do
54-- Calculate a list of used modules based on explicit imports and qualified names
54-- Calculate a list of used modules based on explicit imports and qualified names
55--
55--
56usedModules :: Declaration -> [ModuleName]
56usedModules :: Declaration -> [ModuleName]
57+usedModules d =
57−usedModules = let (f, _, _, _, _) = everythingOnValues (++) forDecls forValues (const []) (const []) (const []) in nub . f
58+ let (f, _, _, _, _) = everythingOnValues (++) forDecls forValues (const []) (const []) (const [])
59+ (g, _, _, _, _) = accumTypes (everythingOnTypes (++) forTypes)
60+ in nub (f d ++ g d)
58 where
61 where
59 forDecls :: Declaration -> [ModuleName]
62 forDecls :: Declaration -> [ModuleName]
60 forDecls (ImportDeclaration mn _ _ _) = [mn]
63 forDecls (ImportDeclaration mn _ _ _) = [mn]
61 forDecls (FixityDeclaration _ _ (Just (Qualified (Just mn) _))) = [mn]
64 forDecls (FixityDeclaration _ _ (Just (Qualified (Just mn) _))) = [mn]
65+ forDecls (TypeInstanceDeclaration _ _ (Qualified (Just mn) _) _ _) = [mn]
62 forDecls _ = []
66 forDecls _ = []
63
67
64 forValues :: Expr -> [ModuleName]
68 forValues :: Expr -> [ModuleName]
65 forValues (Var (Qualified (Just mn) _)) = [mn]
69 forValues (Var (Qualified (Just mn) _)) = [mn]
66 forValues (Constructor (Qualified (Just mn) _)) = [mn]
70 forValues (Constructor (Qualified (Just mn) _)) = [mn]
67− forValues (TypedValue _ _ ty) = forTypes ty
68 forValues _ = []
71 forValues _ = []
69
72
70 forTypes :: Type -> [ModuleName]
73 forTypes :: Type -> [ModuleName]
71 forTypes (TypeConstructor (Qualified (Just mn) _)) = [mn]
74 forTypes (TypeConstructor (Qualified (Just mn) _)) = [mn]
72− forTypes (ConstrainedType cs _) = mapMaybe (\(Qualified mn _, _) -> mn) cs
73 forTypes _ = []
75 forTypes _ = []
74
76
75-- |
77-- |