Lookup module and package defining <<x>?

Has somene already implemented something like: $ghc-pkg --where-from ParseError package parsec: defining modules: Text.ParserCombinators.Parsec.Error, Text.ParserCombinators.Parsec ? lambdabot @index does what I want, but not with my libs installed only locally.. This might be used by any developement system for easily importing modules.. If not I'll start working on this and I'll post again after needing help ;) or finishing It can't be that hard because there is already ghc-pkg list and ghc --show-iface ... Marc

On Fri, 2006-07-21 at 10:12 +0200, Marc Weber wrote:
Has somene already implemented something like:
$ghc-pkg --where-from ParseError package parsec: defining modules: Text.ParserCombinators.Parsec.Error, Text.ParserCombinators.Parsec
Have you tried Hoogle? http://haskell.org/hoogle/ Your example gives me one result which includes the module name: http://haskell.org/hoogle/?q=ParseError Duncan

$ghc-pkg --where-from ParseError package parsec: defining modules: Text.ParserCombinators.Parsec.Error, Text.ParserCombinators.Parsec
Have you tried Hoogle? http://haskell.org/hoogle/ I know it. But I don't know yet which source it takes (haskell - source, haddck html files, ...) ?
My purpose: After having found the a function I want to use it without having to search where does it belong to and where does it come from. I want it beeing as up to date as the installed libraries. That's why I thought it might be best to integrate it into ghc? I don't know wether you've ever prorgammed in Java using Eclipse? After using a type you can press C-S-o to update all imports which will give you the choice which one to use if there is more than one opportunity. It would be nice to have this in haskell, too. Do you think it would be better to integrate it in another tool such like lambdabot or hoogle? Marc

Marc Weber
My purpose: After having found the a function I want to use it without having to search where does it belong to and where does it come from. I want it beeing as up to date as the installed libraries.
You can download Hoogle as a command-line tool, and give it your complete installed libraries to index. Then it will be accurate for your own setup. Of course, you would need to manually update it every time you install a new library.
That's why I thought it might be best to integrate it into ghc?
This kind of tool, though useful, has almost nothing in common with the compiler. Although I suppose it would be useful if Hoogle could read the ghc-pkg file format when indexing all locally-available modules. Regards, Malcolm

Malcolm Wallace wrote:
Marc Weber
wrote: That's why I thought it might be best to integrate it into ghc?
This kind of tool, though useful, has almost nothing in common with the compiler.
Not the compiler, but the interactive environment perhaps...
Although I suppose it would be useful if Hoogle could read the ghc-pkg file format when indexing all locally-available modules.
yes, although I hope it would go through ghc-pkg rather than reading the file directly; the package database is supposed to be private, so we can change its format if necessary. Cheers, Simon

My purpose: After having found the a function I want to use it without having to search where does it belong to and where does it come from. I'm not sure what you are asking for? Where does it come from? Surely
I want it beeing as up to date as the installed libraries. That's why I thought it might be best to integrate it into ghc? I want hoogle to always be as up to date as the latest stable GHC, since that should be the one for most people. I am also working on adding libraries, Gtk is already searchable, more will be with hoogle
Hi, thats just the module name - which hoogle easily gives you. If there is some information that hoogle doesn't provide about "the location" of a module, I'll be happy to add it. 4. This should cover all the libraries you have installed. Of course, they won't match your versions, they'll be the most up to date ones. If this is a problem feel free to install Hoogle locally, generate hoogle databases using haddock with the -hoogle flag. With a bit of shell script magic you should have everything you need to make something that does what you want. And of course, once you have, please release it back to the world :)
Do you think it would be better to integrate it in another tool such like lambdabot or hoogle? If you integrate something with hoogle, then you get it from lambdabot for free, with @hoogle.
Thanks Neil

Hello Marc, Friday, July 21, 2006, 3:21:29 PM, you wrote:
I don't know wether you've ever prorgammed in Java using Eclipse? After using a type you can press C-S-o to update all imports which will give you the choice which one to use if there is more than one opportunity. It would be nice to have this in haskell, too.
there is EclipseFP plugin which supports some of Eclipse features for haskell users
Do you think it would be better to integrate it in another tool such like lambdabot or hoogle?
it will be great if Cabal after library installation runs local hoogle to update its information -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

$ghc-pkg --where-from ParseError package parsec: defining modules: Text.ParserCombinators.Parsec.Error, Text.ParserCombinators.Parsec
?
This is what I've done by now... It took me some days to notice that the ./ghc-pkg symlinks to ghc-pkg-6.5xxxx which calls the ghc-pkg from /usr/lib/... but not my modified version ;) ./ghc-pkg.bin was what I was looking for.. By now you can only search for modules... I want to add support for functions.. I could use ghc -show-iface.. Problem: ghc takes about 0.2 s to launch on my system. Dumping all installed ifaces (ghc -show-iface <list of all hi files>) doesn't take much additional time.. That's why I want to include the MkIface module from ghc.. (beeing in another directory) I'm not sure where to add the -i option in the makefile so that ghc can find the module.. One way would be adding the option to EXTRA_SRCS but I hope there is a better possibility Marc < {-# OPTIONS -fglasgow-exts #-} ---
whereFrom OPTIONS -fglasgow-exts #-} 18,20d17 < #ifdef WHERE_FROM < import MkIface < #endif 185,189d181 < #ifdef WHERE_FROM < " $p where-from {id}\n" ++ < " Which package/module contains this module/ declaration?\n" ++ < "\n" ++ < #endif 237,240d228 < #ifdef WHERE_FROM < ["where-from", id] -> do < whereFrom cli id < #endif 469,500d456 < #ifdef WHERE_FROM < -- ----------------------------------------------------------------------------- < -- Where from find the modul or package containing the id < < whereFrom :: [Flag] -> String -> IO () < whereFrom flags id = < let simple_output = FlagSimpleOutput `elem` flags < in do db_stack <- getPkgDatabases False flags < let all_pkgs = concat (map snd db_stack) :: [InstalledPackageInfo] < -- looking for modules with name id < let exposedModulesMatches = ("exposed matching modules", < concatMap (getPkgNameAndModule exposedModules) all_pkgs ) :: (String, [String]) < let hiddenModulesMatches = ("hidden matching modules", < concatMap (getPkgNameAndModule hiddenModules) all_pkgs ) < -- looking for data < -- looking for type < -- looking for newtype < -- looking for functions < let matchingResult = filter ((/= []).snd) [exposedModulesMatches, hiddenModulesMatches] < case matchingResult of < [] -> putStrLn "no matches found" < results -> do putStrLn "maches :" < mapM_ (\(category, matches) -> putStrLn (category ++ ":") >> mapM_ putStrLn matches) results < < where getPkgNameAndModule modules pkginfo = [ formatFoundModule ((showPackageId.package) pkginfo) m | m <- modules pkginfo, (m == id) ] < formatFoundModule pkg module_ = pkg ++ ": " ++ module_ < scanPackage pkg scanModule = lifM2 (++) (concatMap (scanModule "") (exposedModules pkg)) < (concatMap (scanModule "hidden") (hiddenModules pkg)) < where scanModule hidden_text module_ = < < #endif
participants (6)
-
Bulat Ziganshin
-
Duncan Coutts
-
Malcolm Wallace
-
Marc Weber
-
Neil Mitchell
-
Simon Marlow