git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Refactor - Remove comments + improve intermediary function name
429807fAntoine R. Dumont
psci/Main.hs+5−7
@@ -347,7 +347,7 @@ handleBrowse :: P.ModuleName -> PSCI ()
347handleBrowse moduleName = do
347handleBrowse moduleName = do
348 PSCiState { psciLoadedModules = loadedModules
348 PSCiState { psciLoadedModules = loadedModules
349 , psciImportedFilenames = loadedPaths} <- PSCI $ lift get
349 , psciImportedFilenames = loadedPaths} <- PSCI $ lift get
350− psciIO $ (readModuleTypes loadedModules . findModulePath loadedPaths . N.runModuleName) moduleName >>= putStrLn
350+ psciIO $ (readModuleTypes loadedModules . findKeyModulePath loadedPaths . N.runModuleName) moduleName >>= putStrLn
351 return ()
351 return ()
352 where
352 where
353 moduleToPath :: String -> FilePath
353 moduleToPath :: String -> FilePath
@@ -358,21 +358,19 @@ handleBrowse moduleName = do
358 "Control.Monad.Eff", "Control.Monad.Eff.Unsafe",
358 "Control.Monad.Eff", "Control.Monad.Eff.Unsafe",
359 "Debug.Trace", "Control.Monad.ST"]
359 "Debug.Trace", "Control.Monad.ST"]
360
360
361− -- find the fully qualified module path (key to full module) - "" if not found
361+ -- find the fully qualified module path (key to full module)
362− findModulePath :: [FilePath] -> String -> Either String FilePath
362+ findKeyModulePath :: [FilePath] -> String -> Either String FilePath
363− findModulePath _ [] = Left "Module must be specified."
363+ findKeyModulePath _ [] = Left "Module must be specified."
364− findModulePath filePaths modName =
364+ findKeyModulePath filePaths modName =
365 let partialModulePath = if modName `elem` preludeModules then "/prelude/prelude.purs" else moduleToPath modName in
365 let partialModulePath = if modName `elem` preludeModules then "/prelude/prelude.purs" else moduleToPath modName in
366 case filter (isInfixOf partialModulePath) filePaths of
366 case filter (isInfixOf partialModulePath) filePaths of
367 [] -> Left $ "Module ('" ++ modName ++ "','" ++ partialModulePath ++ "') was not found."
367 [] -> Left $ "Module ('" ++ modName ++ "','" ++ partialModulePath ++ "') was not found."
368 (x:_) -> Right x
368 (x:_) -> Right x
369
369
370− -- retrieve explicit types
371 getSignature (P.PositionedDeclaration _ d) = getSignature d
370 getSignature (P.PositionedDeclaration _ d) = getSignature d
372 getSignature (P.TypeDeclaration ident mtype) = Just $ show ident ++ " :: " ++ prettyPrintType mtype
371 getSignature (P.TypeDeclaration ident mtype) = Just $ show ident ++ " :: " ++ prettyPrintType mtype
373 getSignature _ = Nothing
372 getSignature _ = Nothing
374
373
375− -- pretty print module's signature
376 signatures :: P.Module -> [String]
374 signatures :: P.Module -> [String]
377 signatures (P.Module _ ds _) = mapMaybe getSignature ds
375 signatures (P.Module _ ds _) = mapMaybe getSignature ds
378
376