Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Various simplifications #898

Merged
merged 1 commit into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 5 additions & 9 deletions app/HieWrapper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ main = do

run :: GlobalOpts -> IO ()
run opts = do
let mLogFileName = case optLogFile opts of
Just f -> Just f
Nothing -> Nothing
let mLogFileName = optLogFile opts
Copy link
Collaborator

Choose a reason for hiding this comment

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

👀


logLevel = if optDebugOn opts
then L.DEBUG
Expand Down Expand Up @@ -85,20 +83,18 @@ run opts = do

let
hieBin = "hie-" ++ ghcVersion
backupHieBin = "hie-" ++ reverse (tail $ dropWhile (/='.') $ reverse ghcVersion)
backupHieBin = "hie-" ++ init (dropWhileEnd (/='.') ghcVersion)
candidates' = [hieBin, backupHieBin, "hie"]
candidates = map (++ exeExtension) candidates'

logm $ "hie exe candidates :" ++ show (hieBin,backupHieBin)

let candidates' = [hieBin, backupHieBin, "hie"]
candidates = map (++ exeExtension) candidates'
logm $ "hie exe candidates :" ++ show candidates
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The previous impl didn't list all 3 candidates that the program is searching for. Also switched to dropWhileEnd to avoid the need to reverse twice.


mexes <- traverse findExecutable candidates

case asum mexes of
Nothing -> logm $ "cannot find any hie exe, looked for:" ++ intercalate ", " candidates
Just e -> do
logm $ "found hie exe at:" ++ e
-- putStrLn $ "found hie exe at:" ++ e
args <- getArgs
logm $ "args:" ++ show args
logm "launching ....\n\n\n"
Expand Down
4 changes: 1 addition & 3 deletions app/MainHie.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ main = do

run :: GlobalOpts -> IO ()
run opts = do
let mLogFileName = case optLogFile opts of
Just f -> Just f
Nothing -> Nothing
let mLogFileName = optLogFile opts

logLevel = if optDebugOn opts
then L.DEBUG
Expand Down
7 changes: 5 additions & 2 deletions docs/Hacking.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ To build and test with all of them, use
make test
```

Note that some tests require `liquid` binary to be present in your PATH.
To install it follow the instructions in [liquidhaskell](https://github.com/ucsd-progsys/liquidhaskell/blob/develop/INSTALL.md).

To see what version/compiler you are running

```bash
Expand Down Expand Up @@ -130,7 +133,7 @@ the `plugins` table.

### Operation

When a request is recived from any of the frontends, this is routed to the
When a request is received from any of the frontends, this is routed to the
central dispatcher via a `Chan`. Based on the specified plugin name and
`IdeRequest` `ideCommand` value the appropriate `UiCommand` is identified and
its `uiFunc` is called.
Expand All @@ -144,5 +147,5 @@ type Dispatcher = forall m. (MonadIO m,GHC.GhcMonad m,HasIdeState m) => IdeReque
This type is not the monad used in `HIE`, but does guarantee that it can access
IO and the `HIE` state, which is currently only the table of plugins.

It also makes the `GhcMonad` available. In a fully general version this my not
It also makes the `GhcMonad` available. In a fully general version this may not
be necessary.
2 changes: 1 addition & 1 deletion docs/Protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md

Advantages include widespread tooling and IDE support, and standarisation.
Advantages include widespread tooling and IDE support, and standardization.

Implemented in [LspStdio.hs](../src/Haskell/Ide/Engine/Transport/LspStdio.hs)

Expand Down
2 changes: 1 addition & 1 deletion docs/hcar/2015.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Idris community has done toward an interactive editing environment as well. This
is a deliberately broad scope, the initial versions will be very limited at
first. The sooner we can get started the sooner we will have something concrete
to criticise and improve.
to criticize and improve.

Help is very much needed and wanted so if this is a problem that interests you,
please pitch in! This is not a project just for a small inner circle. Anyone
Expand Down
13 changes: 5 additions & 8 deletions src/Haskell/Ide/Engine/Plugin/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,18 @@ getProjectGhcVersion = do
if isStackProject && isStackInstalled
then do
L.infoM "hie" "Using stack GHC version"
catch (tryCommand "stack ghc -- --version") $ \e -> do
catch (tryCommand "stack ghc -- --numeric-version") $ \e -> do
L.errorM "hie" $ show (e :: SomeException)
L.infoM "hie" "Couldn't find stack version, falling back to plain GHC"
tryCommand "ghc --version"
tryCommand "ghc --numeric-version"
else do
L.infoM "hie" "Using plain GHC version"
tryCommand "ghc --version"
tryCommand "ghc --numeric-version"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Didn't know this existed, very handy!


where
tryCommand cmd =
crackGhcVersion <$> readCreateProcess (shell cmd) ""
-- "The Glorious Glasgow Haskell Compilation System, version 8.4.3\n"
-- "The Glorious Glasgow Haskell Compilation System, version 8.4.2\n"
crackGhcVersion :: String -> String
crackGhcVersion st = reverse $ takeWhile (/=' ') $ tail $ reverse st
-- Drop '\n' from the output like "7.10.3\n", "8.4.3\n"
init <$> readCreateProcess (shell cmd) ""

hieGhcVersion :: String
hieGhcVersion = VERSION_ghc
Expand Down
4 changes: 1 addition & 3 deletions src/Haskell/Ide/Engine/Transport/LspStdio.hs
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,7 @@ requestDiagnostics DiagnosticsRequest{trigger, file, trackingNumber, documentVer
forM_ dss $ \(pid,ds) -> do
logm $ "requestDiagnostics: calling diagFunc for plugin:" ++ show pid
let
enabled = case Map.lookup pid dpsEnabled of
Nothing -> True
Just flag -> flag
enabled = Map.findWithDefault True pid dpsEnabled
publishDiagnosticsIO = Core.publishDiagnosticsFunc lf
maxToSend = maybe 50 maxNumberOfProblems mc
sendOne (fileUri,ds') = do
Expand Down