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

Commit 5707678

Browse files
author
Jan Hrček
committed
Various simplifications
1 parent 6d12938 commit 5707678

File tree

7 files changed

+19
-27
lines changed

7 files changed

+19
-27
lines changed

app/HieWrapper.hs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ main = do
5454

5555
run :: GlobalOpts -> IO ()
5656
run opts = do
57-
let mLogFileName = case optLogFile opts of
58-
Just f -> Just f
59-
Nothing -> Nothing
57+
let mLogFileName = optLogFile opts
6058

6159
logLevel = if optDebugOn opts
6260
then L.DEBUG
@@ -85,20 +83,18 @@ run opts = do
8583

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

90-
logm $ "hie exe candidates :" ++ show (hieBin,backupHieBin)
91-
92-
let candidates' = [hieBin, backupHieBin, "hie"]
93-
candidates = map (++ exeExtension) candidates'
90+
logm $ "hie exe candidates :" ++ show candidates
9491

9592
mexes <- traverse findExecutable candidates
9693

9794
case asum mexes of
9895
Nothing -> logm $ "cannot find any hie exe, looked for:" ++ intercalate ", " candidates
9996
Just e -> do
10097
logm $ "found hie exe at:" ++ e
101-
-- putStrLn $ "found hie exe at:" ++ e
10298
args <- getArgs
10399
logm $ "args:" ++ show args
104100
logm "launching ....\n\n\n"

app/MainHie.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ main = do
100100

101101
run :: GlobalOpts -> IO ()
102102
run opts = do
103-
let mLogFileName = case optLogFile opts of
104-
Just f -> Just f
105-
Nothing -> Nothing
103+
let mLogFileName = optLogFile opts
106104

107105
logLevel = if optDebugOn opts
108106
then L.DEBUG

docs/Hacking.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ To build and test with all of them, use
1717
make test
1818
```
1919

20+
Note that some tests require `liquid` binary to be present in your PATH.
21+
To install it follow the instructions in [liquidhaskell](https://github.com/ucsd-progsys/liquidhaskell/blob/develop/INSTALL.md).
22+
2023
To see what version/compiler you are running
2124

2225
```bash
@@ -130,7 +133,7 @@ the `plugins` table.
130133

131134
### Operation
132135

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

147-
It also makes the `GhcMonad` available. In a fully general version this my not
150+
It also makes the `GhcMonad` available. In a fully general version this may not
148151
be necessary.

docs/Protocol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

7-
Advantages include widespread tooling and IDE support, and standarisation.
7+
Advantages include widespread tooling and IDE support, and standardization.
88

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

docs/hcar/2015.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
Idris community has done toward an interactive editing environment as well. This
2626
is a deliberately broad scope, the initial versions will be very limited at
2727
first. The sooner we can get started the sooner we will have something concrete
28-
to criticise and improve.
28+
to criticize and improve.
2929

3030
Help is very much needed and wanted so if this is a problem that interests you,
3131
please pitch in! This is not a project just for a small inner circle. Anyone

src/Haskell/Ide/Engine/Plugin/Base.hs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,18 @@ getProjectGhcVersion = do
111111
if isStackProject && isStackInstalled
112112
then do
113113
L.infoM "hie" "Using stack GHC version"
114-
catch (tryCommand "stack ghc -- --version") $ \e -> do
114+
catch (tryCommand "stack ghc -- --numeric-version") $ \e -> do
115115
L.errorM "hie" $ show (e :: SomeException)
116116
L.infoM "hie" "Couldn't find stack version, falling back to plain GHC"
117-
tryCommand "ghc --version"
117+
tryCommand "ghc --numeric-version"
118118
else do
119119
L.infoM "hie" "Using plain GHC version"
120-
tryCommand "ghc --version"
120+
tryCommand "ghc --numeric-version"
121121

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

130127
hieGhcVersion :: String
131128
hieGhcVersion = VERSION_ghc

src/Haskell/Ide/Engine/Transport/LspStdio.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,7 @@ requestDiagnostics DiagnosticsRequest{trigger, file, trackingNumber, documentVer
810810
forM_ dss $ \(pid,ds) -> do
811811
logm $ "requestDiagnostics: calling diagFunc for plugin:" ++ show pid
812812
let
813-
enabled = case Map.lookup pid dpsEnabled of
814-
Nothing -> True
815-
Just flag -> flag
813+
enabled = Map.findWithDefault True pid dpsEnabled
816814
publishDiagnosticsIO = Core.publishDiagnosticsFunc lf
817815
maxToSend = maybe 50 maxNumberOfProblems mc
818816
sendOne (fileUri,ds') = do

0 commit comments

Comments
 (0)