Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Merge ghc-imported-from into ghc-mod #810

Closed
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
2485221
Merging the ghc-imported-from utility.
carlohamalainen Jul 12, 2016
5126454
Dependencies for imported-from command.
carlohamalainen Jul 12, 2016
4e4f69c
Add imported-from command.
carlohamalainen Jul 12, 2016
bd62eb0
Fix a type error.
carlohamalainen Jul 12, 2016
5d26b71
Remove bound on process-streaming.
carlohamalainen Jul 12, 2016
6339f63
Fix bounds for haddock-api with ghc 7.x and 8.x
carlohamalainen Jul 12, 2016
875b513
Revert ghc-mod.cabal to current master.
carlohamalainen Jul 15, 2016
ae39594
Import in alphabetical position.
carlohamalainen Jul 15, 2016
47becac
LANGUAGE extensions on one line.
carlohamalainen Jul 15, 2016
ffc755b
Remove unused import.
carlohamalainen Jul 15, 2016
cfb9693
Revert to current master.
carlohamalainen Jul 15, 2016
07e4be3
Remove dependency on System.Process.Streaming
carlohamalainen Jul 15, 2016
af4e620
Use gmReadProcess. Builds and tests pass with ghc-7.10.3
carlohamalainen Jul 15, 2016
1736e24
Fix import for Control.Applicative
carlohamalainen Jul 16, 2016
d9c9477
Avoid use of "traverse" which is not in ghc-7.6.3
carlohamalainen Jul 16, 2016
7b8d5a7
Builds on ghc-7.6.3; added some fallback cases for earlier versions o…
carlohamalainen Jul 16, 2016
7fa7b12
Move #if things to Language.Haskell.GhcMod.Gap.
carlohamalainen Jul 16, 2016
1557ef1
Add type sig.
carlohamalainen Jul 16, 2016
d276260
Remove definition of tdflags (also gets rid of unsafeGlobalDynFlags).
carlohamalainen Jul 17, 2016
7106525
Remove constraints on GmOut and GmLog.
carlohamalainen Jul 17, 2016
048eaac
Fewer imports; move moduleNameToHtmlFile into a where clause.
carlohamalainen Jul 17, 2016
13e5cda
Move filterMatchingQualifiedImport to a where clause; tidy up
carlohamalainen Jul 17, 2016
f52077c
Use parameter of ```gmLog GmDebug``` instead of passing ```""```.
carlohamalainen Jul 17, 2016
50a52d2
Reformat some very long lines.
carlohamalainen Jul 17, 2016
1339dc5
Merge changes from master.
carlohamalainen Jul 17, 2016
ec38b27
Merging changes from master.
carlohamalainen Jul 17, 2016
84579ef
Tweaks for building on earlier versions of ghc.
carlohamalainen Jul 17, 2016
b94f2f4
Adjust ghc version bound on ghcIdeclHiding.
carlohamalainen Jul 17, 2016
6b11e9d
Tweaks for building on GHC8.
carlohamalainen Jul 19, 2016
ae4badb
Use exit code instead of printing SUCCESS / FAIL.
carlohamalainen Jul 19, 2016
fb1c146
Add ImportedFromSpec to test suite.
carlohamalainen Jul 19, 2016
fa1417a
Use top-level error GMEMissingHaddock when missing haddock html.
carlohamalainen Jul 19, 2016
40e3daf
Use GMError type instead of calling plain "error".
carlohamalainen Jul 19, 2016
b1c1b2a
Tidying up logging.
carlohamalainen Jul 20, 2016
9eb0cc8
Add note about setting documentation:True in .cabal/config.
carlohamalainen Jul 24, 2016
6f83fab
Tweak for resolver on internal symbols (tested with GHC8; added testc…
carlohamalainen Jul 24, 2016
2edda72
Forgot "$$".
carlohamalainen Jul 24, 2016
704cff6
Drop parens in qualified name. New in GHC8?
carlohamalainen Jul 24, 2016
cdbe0ef
Adding some more test cases.
carlohamalainen Jul 29, 2016
e2f6092
Remove dependency on parsec.
carlohamalainen Jul 30, 2016
f6ba25b
Tidyup some warnings.
carlohamalainen Jul 30, 2016
0961feb
Accidentally removed import of Control.Applicative.
carlohamalainen Jul 30, 2016
ea1d4a0
Instead of throwing an exception if the haddock file is missing,
carlohamalainen Aug 8, 2016
c37907c
Improved tests for imported-from command. Actually checks the output
carlohamalainen Aug 8, 2016
e413cea
Merge remote-tracking branch 'remotes/upstream/master' into ghc-impor…
carlohamalainen Aug 8, 2016
5eefa23
Don't use Python-style leading underscore.
carlohamalainen Aug 9, 2016
122cfd5
Remove dead code.
carlohamalainen Aug 9, 2016
f3c9268
Use things from Control.Monad.Trans.Maybe.
carlohamalainen Aug 9, 2016
fc02ddc
Remove unused dependency.
carlohamalainen Aug 9, 2016
a9fa573
Remove stackoverflow snippet.
carlohamalainen Aug 9, 2016
4897f16
Remove another ```fromMaybe (throw ...)``` pattern.
carlohamalainen Aug 9, 2016
2be2742
fail instead of throw; tidy up some definitions.
carlohamalainen Aug 9, 2016
8d4d2c7
Use a view pattern.
carlohamalainen Aug 9, 2016
21a81b2
Tidying up.
carlohamalainen Aug 9, 2016
e36a3c3
Flag for cabal install is --only-dependencies not --dependencies-only.
carlohamalainen Aug 9, 2016
83f27c6
Avoid use of ```nub```.
carlohamalainen Aug 9, 2016
c995e15
Note on use of ```last```.
carlohamalainen Aug 9, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions Language/Haskell/GhcMod/ImportedFrom.hs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,10 @@ refineVisibleExports getHaddockInterfaces exports = mapM f exports
qexports = qualifiedExports mexports -- e.g. ["base-4.8.2.0:GHC.Base.Just", ...]
mVisibleExportsMap <- getVisibleExports getHaddockInterfaces pname

let visibleExportsMap = fromMaybe (throw $ GMEString $ "ImportedFrom: visible exports map is Nothing") mVisibleExportsMap
visibleExportsMap <- case mVisibleExportsMap of
Copy link
Owner

@DanielG DanielG Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you misunderstood, there are three kinds of failures:

  • A pure exception
do let foo = throw "whatever"
   return foo
  • An excpetion where a monadic value should be
do throw "whatever"
  • An ExceptT/MonadError failure
do throwError $ GMEString "whatever"

The differences are subtle but in general the first two kinds are annoying since you need to explicitly catch the exceptions whereas the last one just always gets returned as a Left by runGhcModT.

The difference between 1) and 2) is important though: throw "whatever" >> return "foo" will always crash when run, let foo = throw "whatever" in return (foo, "bar") will only crash when you touch the fst of that tuple! (lazyness and such)

The GhcModError stuff should always be returned via throwError where possible. All you really had to do was to replace fromMaybe with liftMaybe :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fail is equivalent to throwError . GMEString which is why I suggested you use that before.

Nothing -> throw $ GMEString $ "ImportedFrom: visible exports map is Nothing"
Just x -> return x

gmLog GmDebug "visibleExportsMap" $ strDoc $ show visibleExportsMap

let thisModVisibleExports0 = M.lookup thisModuleName visibleExportsMap
Expand All @@ -563,9 +566,9 @@ refineVisibleExports getHaddockInterfaces exports = mapM f exports
let thisModVisibleExports = case thisModVisibleExports0 of
Copy link
Owner

@DanielG DanielG Aug 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need an explicit case, thisModVisibleExports0 mplus Just pname' would do.

Just ve -> ve
Nothing -> let pname' = ((head $ splitOn "-" pname) ++ ":" ++ thisModuleName) in
fromMaybe
(throw $ GMENoVisibleExports thisModuleName pname')
(M.lookup pname' visibleExportsMap)
case M.lookup pname' visibleExportsMap of
Nothing -> throw $ GMENoVisibleExports thisModuleName pname'
Just ve -> ve

let qexports' = filter (hasPostfixMatch thisModVisibleExports) qexports

Expand Down Expand Up @@ -733,18 +736,16 @@ guessHaddockUrl modSum targetFile targetModule symbol lineNr colNr ghcPkg readPr
gmLog GmDebug "guessHaddockUrl" $ strDoc $ "lastMatchPackageName: " ++ lastMatchPackageName
gmLog GmDebug "guessHaddockUrl" $ strDoc $ "mhaddock: " ++ show mhaddock

let haddock = fromMaybe
(throw $ GMEString $ "ImportedFrom: ghcPkgHaddockUrl failed to find path to HTML file.")
mhaddock

let f = haddock </> (moduleNameToHtmlFile lastMatchModule)
case mhaddock of
Nothing -> throw $ GMEString $ "ImportedFrom: ghcPkgHaddockUrl failed to find path to HTML file."
Just haddock -> do let f = haddock </> (moduleNameToHtmlFile lastMatchModule)

let mySymbol' = case mySymbol of
MySymbolSysQualified s -> s
MySymbolUserQualified s -> s
let mySymbol' = case mySymbol of
MySymbolSysQualified s -> s
MySymbolUserQualified s -> s

return $ mySymbol' ++ " " ++ lastMatchModule ++ " file://" ++ f
++ " " ++ toHackageUrl f lastMatchPackageName lastMatchModule
return $ mySymbol' ++ " " ++ lastMatchModule ++ " file://" ++ f
++ " " ++ toHackageUrl f lastMatchPackageName lastMatchModule

where
-- Convert a module name string, e.g. @Data.List@ to @Data-List.html@.
Expand Down