carlohamalainen / ghc-imported-from

For a given Haskell source file, determine where a symbol is imported from
BSD 3-Clause "New" or "Revised" License
26 stars 2 forks source link

How do you actually use this? #8

Closed chrisdone closed 10 years ago

chrisdone commented 10 years ago

I tried the example line from the README and got:

chris@retina:~$ ghc-imported-from /home/chris/Emacs/packages/structured-haskell-mode/src/Main.hs Main ParseResult 23 37
ghc-imported-from: Maybe.fromJust: Nothing
chris@retina:~$ ghc-imported-from /home/chris/Emacs/packages/structured-haskell-mode/src/Main.hs Main ParseResult 23 37 --ghc-pkg-options 
ghc-imported-from: Prelude.tail: empty list
carlohamalainen commented 10 years ago

Sorry, the argument parsing is flaky, you must pass the two options things even if they are empty, e.g.

ghc-imported-from /home/chris/Emacs/packages/structured-haskell-mode/src/Main.hs Main ParseResult 23 37 --ghc-options --ghc-pkg-options
chrisdone commented 10 years ago

Hm, that bails out in a different way:

chris@retina:~$ ghc-imported-from /home/chris/Emacs/packages/structured-haskell-mode/src/Main.hs Main ParseResult 23 37 --ghc-options --ghc-pkg-options
GhcOptions []
GhcPkgOptions []
ghc-imported-from: panic! (the 'impossible' happened)
  (GHC version 7.6.2 for x86_64-unknown-linux):
        Maybe.fromJust: Nothing

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Nevermind.

carlohamalainen commented 10 years ago

Did you build structured-haskell-mode in a sandbox or in the 'user' cabal area?

I cloned from github and built in a sandbox:

git clone https://github.com/chrisdone/structured-haskell-mode.git
cd structured-haskell-mode
cabal sandbox init
cabal install --haddock-hyperlink-source --dependencies-only

then it works with your example:

$ ghc-imported-from src/Main.hs Main ParseResult 23 37 --ghc-options --ghc-pkg-options
GhcOptions []
GhcPkgOptions []
targetFile: src/Main.hs
targetModule: Main
symbol: "ParseResult"
line nr: 23
col nr: 37
getTextualImports: ghcOpts1: ["-no-user-package-db","-package-db","/home/carlo/work/github/structured-haskell-mode/.cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d"]
getTextualImports: ghcOpts2: ["-no-user-package-db","-package-db","/home/carlo/work/github/structured-haskell-mode/.cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d","-XHaskell98"]
haskellModuleNames: ["Prelude","System.IO","System.Environment","Language.Haskell.Exts.Annotated.Fixity","Language.Haskell.Exts.Annotated","Data.Maybe","Data.Data","Data.Char","Control.Applicative"]
qualified names: []
matchingAsImport: Nothing
postMatches:  []
symbol': ParseResult
maybeExtraModule: Nothing
haskellModuleNames': ["Prelude","System.IO","System.Environment","Language.Haskell.Exts.Annotated.Fixity","Language.Haskell.Exts.Annotated","Data.Maybe","Data.Data","Data.Char","Control.Applicative"]
smatches: []
symbol'': ParseResult
name: Language.Haskell.Exts.ParseMonad.ParseResult
definedIn: haskell-src-exts-1.14.0:Language.Haskell.Exts.ParseMonad
bpms: []
concat $ map symbolImportedFrom lookUp: [Language.Haskell.Exts.Annotated]
importedFrom: Just "Language.Haskell.Exts.Annotated"
ghc-pkg ["find-module","Language.Haskell.Exts.Annotated","--simple-output","--global","--user","--no-user-package-db","--package-db","/home/carlo/work/github/structured-haskell-mode/.cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d"]
ghcPkgFindModule stdout: haskell-src-exts-1.14.0

ghcPkgFindModule stderr: 
ghcPkgFindModule result: Just "haskell-src-exts-1.14.0"
base: : Just "Language-Haskell-Exts-Annotated.html"
ghc-pkg ["field","haskell-src-exts-1.14.0","haddock-html","--global","--user","--no-user-package-db","--package-db","/home/carlo/work/github/structured-haskell-mode/.cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d"]
haddock: Just "/home/carlo/work/github/structured-haskell-mode/.cabal-sandbox/share/doc/x86_64-linux-ghc-7.6.3/haskell-src-exts-1.14.0/html"
foundModule: Just "haskell-src-exts-1.14.0"
SUCCESS: file:///home/carlo/work/github/structured-haskell-mode/.cabal-sandbox/share/doc/x86_64-linux-ghc-7.6.3/haskell-src-exts-1.14.0/html/Language-Haskell-Exts-Annotated.html