git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Add a hack to be able to browse prelude's signatures.
909deffAntoine R. Dumont
psci/Main.hs+10−4
@@ -353,13 +353,19 @@ handleBrowse moduleName = do
353 moduleToPath :: String -> FilePath
353 moduleToPath :: String -> FilePath
354 moduleToPath = (pathSeparator:) . (++ ".purs") . map (\x -> if x == '.' then pathSeparator else x) . N.runModuleName . N.moduleNameFromString
354 moduleToPath = (pathSeparator:) . (++ ".purs") . map (\x -> if x == '.' then pathSeparator else x) . N.runModuleName . N.moduleNameFromString
355
355
356+ -- HACK - permit to `:b` prelude modules - I do not know better
357+ preludeModules = ["Prelude", "Data.Function", "Data.Eq", "Prelude.Unsafe",
358+ "Control.Monad.Eff", "Control.Monad.Eff.Unsafe",
359+ "Debug.Trace", "Control.Monad.ST"]
360+
356 -- find the fully qualified module path (key to full module) - "" if not found
361 -- find the fully qualified module path (key to full module) - "" if not found
357 findModulePath :: [FilePath] -> String -> Either String FilePath
362 findModulePath :: [FilePath] -> String -> Either String FilePath
358 findModulePath _ [] = Left "Module must be specified."
363 findModulePath _ [] = Left "Module must be specified."
359− findModulePath filePaths modName = let partialModulePath = moduleToPath modName in
364+ findModulePath filePaths modName =
365+ let partialModulePath = if modName `elem` preludeModules then "/prelude/prelude.purs" else moduleToPath modName in
360− case filter (isInfixOf partialModulePath) filePaths of
366+ case filter (isInfixOf partialModulePath) filePaths of
361− [] -> Left $ "Module ('" ++ modName ++ "','" ++ partialModulePath ++ "') was not found."
367+ [] -> Left $ "Module ('" ++ modName ++ "','" ++ partialModulePath ++ "') was not found."
362− (x:_) -> Right x
368+ (x:_) -> Right x
363
369
364 -- retrieve explicit types
370 -- retrieve explicit types
365 getSignature (P.PositionedDeclaration _ d) = getSignature d
371 getSignature (P.PositionedDeclaration _ d) = getSignature d