git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Deal with edge case (no module name or bad one)
541e303Antoine R. Dumont
psci/Main.hs+8−6
@@ -360,15 +360,17 @@ handleBrowse moduleName = do
360 st <- PSCI $ lift get
360 st <- PSCI $ lift get
361 e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st) []
361 e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st) []
362 case e of
362 case e of
363− Left err -> PSCI $ outputStrLn err
363+ Left err -> PSCI $ outputStrLn err
364 Right env' ->
364 Right env' ->
365 let namesEnv = P.names env'
365 let namesEnv = P.names env'
366 moduleNamesIdent = (filter ((== moduleName) . fst) . M.keys) namesEnv
366 moduleNamesIdent = (filter ((== moduleName) . fst) . M.keys) namesEnv
367− in (PSCI
367+ in case moduleNamesIdent of
368+ [] -> (PSCI . outputStrLn) "A correct module name must be specified. See `:s loaded` command for a list of those."
369+ _ -> ( PSCI
368− . outputStrLn
370+ . outputStrLn
369− . unlines
371+ . unlines
370− . sort
372+ . sort
371− . map (showType . findType namesEnv)) moduleNamesIdent
373+ . map (showType . findType namesEnv)) moduleNamesIdent
372 where findType :: M.Map (P.ModuleName, P.Ident) (P.Type, P.NameKind, P.NameVisibility) -> (P.ModuleName, P.Ident) -> (P.Ident, Maybe (P.Type, P.NameKind, P.NameVisibility))
374 where findType :: M.Map (P.ModuleName, P.Ident) (P.Type, P.NameKind, P.NameVisibility) -> (P.ModuleName, P.Ident) -> (P.Ident, Maybe (P.Type, P.NameKind, P.NameVisibility))
373 findType envNames m@(_, mIdent) = (mIdent, M.lookup m envNames)
375 findType envNames m@(_, mIdent) = (mIdent, M.lookup m envNames)
374 showType :: (P.Ident, Maybe (P.Type, P.NameKind, P.NameVisibility)) -> String
376 showType :: (P.Ident, Maybe (P.Type, P.NameKind, P.NameVisibility)) -> String