Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Rename hie-core to ghcide (#2820)
Browse files Browse the repository at this point in the history
* Rename hie-core to ghcide

The name `hie-core` has caused a lot of confusion as to how we relate
to haskell-ide-engine so changing it should hopefully help with that.
I also think that ghcide is still a good name once we hopefully
integrate with haskell-ide-engine more closely.

The name ghcide seems to have a reasonable amount of support on
Twitter https://twitter.com/ndm_haskell/status/1170681262987710464
which is of course the only good way to come up with names.

* Add a readme that points people to the new directory.

* Fix bogus replacements

* Use a proper link

* links are hard
  • Loading branch information
cocreature authored and garyverhaegen-da committed Sep 10, 2019
1 parent 5ac4265 commit 5da86c3
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 79 deletions.
21 changes: 0 additions & 21 deletions .ghci

This file was deleted.

8 changes: 4 additions & 4 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ hidden = [
]

da_haskell_library(
name = "hie-core",
name = "ghcide",
srcs = glob(["src/**/*.hs"]),
hackage_deps = depends + [
"ghc-lib",
Expand All @@ -83,7 +83,7 @@ cc_library(
) if not is_windows else None

da_haskell_library(
name = "hie-core-public",
name = "ghcide-public",
srcs = glob(["src/**/*.hs"]),
compiler_flags = ["-DGHC_STABLE"],
hackage_deps = depends + [
Expand All @@ -104,7 +104,7 @@ da_haskell_library(
)

da_haskell_binary(
name = "hie-core-exe",
name = "ghcide-exe",
srcs = glob(["exe/**/*.hs"]),
hackage_deps = [
"base",
Expand All @@ -124,6 +124,6 @@ da_haskell_binary(
src_strip_prefix = "test",
visibility = ["//visibility:public"],
deps = [
"hie-core-public",
"ghcide-public",
],
)
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# `hie-core` (Haskell IDE engine)
# `ghcide`

Our vision is that you should build an IDE by combining:


<img style="float:right;" src="img/vscode2.png"/>

* [`hie-bios`](https://github.com/mpickering/hie-bios) for determining where your files are, what are their dependencies, what extensions are enabled and so on;
* `hie-core` (i.e. this library) for defining how to type check, when to type check, and producing diagnostic messages;
* `ghcide` (i.e. this library) for defining how to type check, when to type check, and producing diagnostic messages;
* A bunch of plugins that haven't yet been written, e.g. [`hie-hlint`](https://github.com/ndmitchell/hlint) and [`hie-ormolu`](https://github.com/tweag/ormolu), to choose which features you want;
* [`haskell-lsp`](https://github.com/alanz/haskell-lsp) for sending those messages to a [Language Server Protocol (LSP)](https://microsoft.github.io/language-server-protocol/) server;
* An extension for your editor. We provide a [VS Code extension](https://code.visualstudio.com/api) as `extension` in this directory, although the components work in other LSP editors too (see below for instructions using Emacs).
Expand All @@ -15,25 +15,25 @@ There are more details about our approach [in this blog post](https://4ta.uk/p/s

## Using it

### Install `hie-core`
### Install `ghcide`

#### With Nix

[See hie-core-nix repository](https://github.com/hercules-ci/hie-core-nix)

#### With Cabal or Stack

First install the `hie-core` binary using `stack` or `cabal`, e.g.
First install the `ghcide` binary using `stack` or `cabal`, e.g.

1. `git clone https://github.com/digital-asset/daml.git`
2. `cd daml/compiler/hie-core`
2. `cd daml/compiler/ghcide`
3. `cabal install` or `stack install` (and make sure `~/.local/bin` is on your `$PATH`)

It's important that `hie-core` is compiled with the same compiler you use to build your projects.
It's important that `ghcide` is compiled with the same compiler you use to build your projects.

### Test `hie-core`
### Test `ghcide`

Next, check that `hie-core` is capable of loading your code. Change to the project directory and run `hie-core`, which will try and load everything using the same code as the IDE, but in a way that's much easier to understand. For example, taking the example of [`shake`](https://github.com/ndmitchell/shake), running `hie-core` gives some error messages and warnings before reporting at the end:
Next, check that `ghcide` is capable of loading your code. Change to the project directory and run `ghcide`, which will try and load everything using the same code as the IDE, but in a way that's much easier to understand. For example, taking the example of [`shake`](https://github.com/ndmitchell/shake), running `ghcide` gives some error messages and warnings before reporting at the end:

```
Files that worked: 152
Expand All @@ -49,21 +49,21 @@ Done

Of the 158 files in Shake, as of this moment, 152 can be loaded by the IDE, but 6 can't (error messages for the reasons they can't be loaded are given earlier). The failing files are all prototype work or test output, meaning I can confidently use Shake.

The `hie-core` executable mostly relies on [`hie-bios`](https://github.com/mpickering/hie-bios) to do the difficult work of setting up your GHC environment. If it doesn't work, see [the `hie-bios` manual](https://github.com/mpickering/hie-bios#readme) to get it working. My default fallback is to figure it out by hand and create a `direct` style [`hie.yaml`](https://github.com/ndmitchell/shake/blob/master/hie.yaml) listing the command line arguments to load the project.
The `ghcide` executable mostly relies on [`hie-bios`](https://github.com/mpickering/hie-bios) to do the difficult work of setting up your GHC environment. If it doesn't work, see [the `hie-bios` manual](https://github.com/mpickering/hie-bios#readme) to get it working. My default fallback is to figure it out by hand and create a `direct` style [`hie.yaml`](https://github.com/ndmitchell/shake/blob/master/hie.yaml) listing the command line arguments to load the project.

Once you have got `hie-core` working outside the editor, the next step is to pick which editor to integrate with.
Once you have got `ghcide` working outside the editor, the next step is to pick which editor to integrate with.

### Using with VS Code

Install the VS code extension (see https://code.visualstudio.com/docs/setup/mac for details on adding `code` to your `$PATH`):

1. `cd compiler/hie-core/extension`
1. `cd compiler/ghcide/extension`
2. `npm ci`
3. `npm install vsce --global` (may require `sudo`)
4. `vsce package`
5. `code --install-extension hie-core-0.0.1.vsix`
5. `code --install-extension ghcide-0.0.1.vsix`

Now openning a `.hs` file should work with `hie-core`.
Now openning a `.hs` file should work with `ghcide`.

### Using with Emacs

Expand All @@ -86,7 +86,7 @@ If you don't already have [MELPA](https://melpa.org/#/) package installation con
(use-package lsp-haskell
:ensure t
:config
(setq lsp-haskell-process-path-hie "hie-core")
(setq lsp-haskell-process-path-hie "ghcide")
(setq lsp-haskell-process-args-hie '())
;; Comment/uncomment this line to see interactions between lsp client/server.
;;(setq lsp-log-io t)
Expand All @@ -103,7 +103,7 @@ Add this to your vim config:
let g:LanguageClient_rootMarkers = ['*.cabal', 'stack.yaml']
let g:LanguageClient_serverCommands = {
\ 'rust': ['rls'],
\ 'haskell': ['hie-core', '--lsp'],
\ 'haskell': ['ghcide', '--lsp'],
\ }
```

Expand All @@ -116,8 +116,8 @@ Add this to your vim config:

```vim
au User lsp_setup call lsp#register_server({
\ 'name': 'hie-core',
\ 'cmd': {server_info->['/your/path/to/hie-core', '--lsp']},
\ 'name': 'ghcide',
\ 'cmd': {server_info->['/your/path/to/ghcide', '--lsp']},
\ 'whitelist': ['haskell'],
\ })
```
Expand Down
2 changes: 1 addition & 1 deletion exe/Arguments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ getArguments = execParser opts
opts = info (arguments <**> helper)
( fullDesc
<> progDesc "Used as a test bed to check your IDE will work"
<> header "hie-core - the core of a Haskell IDE")
<> header "ghcide - the core of a Haskell IDE")

arguments :: Parser Arguments
arguments = Arguments
Expand Down
2 changes: 1 addition & 1 deletion exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ main :: IO ()
main = do
-- WARNING: If you write to stdout before runLanguageServer
-- then the language server will not work
hPutStrLn stderr $ "Starting hie-core (GHC v" ++ showVersion compilerVersion ++ ")"
hPutStrLn stderr $ "Starting ghcide (GHC v" ++ showVersion compilerVersion ++ ")"
Arguments{..} <- getArguments

-- lock to avoid overlapping output on stdout
Expand Down
2 changes: 1 addition & 1 deletion extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hie-core",
"displayName": "hie-core",
"name": "ghcide",
"displayName": "ghcide",
"publisher": "digitalasset",
"repository": {
"type" : "git",
Expand Down Expand Up @@ -31,8 +31,8 @@
"properties": {
"hic.executablePath": {
"type": "string",
"default": "hie-core",
"description": "The location of your hie-core executable"
"default": "ghcide",
"description": "The location of your ghcide executable"
},
"hic.arguments": {
"type": "string",
Expand Down
4 changes: 2 additions & 2 deletions hie-core-daml.sh → ghcide-daml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ cd "$(dirname "$0")"/../..
export RULES_HASKELL_EXEC_ROOT=$PWD/
ENV_FILE=$(mktemp)
ARGS_FILE=$(mktemp)
bazel build //compiler/hie-core:hie-core-exe >/dev/null 2>&1
bazel build //compiler/ghcide:ghcide-exe >/dev/null 2>&1
bazel run --define hie_bios_ghci=True //compiler/damlc:damlc@ghci -- "$ENV_FILE" "$ARGS_FILE" >/dev/null 2>&1
source "$ENV_FILE"
export HIE_BIOS_ARGS="$ARGS_FILE"
./bazel-bin/compiler/hie-core/hie-core-exe $@
./bazel-bin/compiler/ghcide/ghcide-exe $@

10 changes: 5 additions & 5 deletions hie-core.cabal → ghcide.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 1.20
build-type: Simple
category: Development
name: hie-core
name: ghcide
version: 0.0.1
license: Apache-2.0
license-file: LICENSE
Expand Down Expand Up @@ -114,7 +114,7 @@ library
Development.IDE.Spans.Documentation
Development.IDE.Spans.Type

executable hie-core
executable ghcide
default-language: Haskell2010
hs-source-dirs: exe
ghc-options: -threaded
Expand All @@ -130,7 +130,7 @@ executable hie-core
ghc,
haskell-lsp,
hie-bios,
hie-core,
ghcide,
optparse-applicative,
shake,
text
Expand All @@ -142,11 +142,11 @@ executable hie-core
TupleSections
ViewPatterns

test-suite hie-core-tests
test-suite ghcide-tests
type: exitcode-stdio-1.0
default-language: Haskell2010
build-tool-depends:
hie-core:hie-core
ghcide:ghcide
build-depends:
base,
containers,
Expand Down
4 changes: 2 additions & 2 deletions install.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:: Copyright (c) 2019 The DAML Authors. All rights reserved.
:: SPDX-License-Identifier: Apache-2.0

@REM Install hie-core where cabal install would put it on Windows
@REM Install ghcide where cabal install would put it on Windows
@REM but avoid checking configure or installing local libraries (faster)
ghc Main -o dist\obj\hie-core.exe -XBangPatterns -XDeriveGeneric -XGeneralizedNewtypeDeriving -XLambdaCase -XNamedFieldPuns -XRecordWildCards -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XViewPatterns -package=ghc -DGHC_STABLE -isrc -iexe -outputdir dist\obj && copy dist\obj\hie-core.exe %AppData%\cabal\bin\hie-core.exe
ghc Main -o dist\obj\ghcide.exe -XBangPatterns -XDeriveGeneric -XGeneralizedNewtypeDeriving -XLambdaCase -XNamedFieldPuns -XRecordWildCards -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XViewPatterns -package=ghc -DGHC_STABLE -isrc -iexe -outputdir dist\obj && copy dist\obj\ghcide.exe %AppData%\cabal\bin\ghcide.exe
6 changes: 3 additions & 3 deletions src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,16 @@ runCpp dflags filename contents = withTempDir $ \dir -> do
dflags <- return $ addIncludePathsQuote (takeDirectory filename) dflags

-- Location information is wrong, so we fix that by patching it afterwards.
let inp = dir </> "___HIE_CORE_MAGIC___"
let inp = dir </> "___GHCIDE_MAGIC___"
withBinaryFile inp WriteMode $ \h ->
hPutStringBuffer h contents
doCpp dflags True inp out

-- Fix up the filename in lines like:
-- # 1 "C:/Temp/extra-dir-914611385186/___HIE_CORE_MAGIC___"
-- # 1 "C:/Temp/extra-dir-914611385186/___GHCIDE_MAGIC___"
let tweak x
| Just x <- stripPrefix "# " x
, "___HIE_CORE_MAGIC___" `isInfixOf` x
, "___GHCIDE_MAGIC___" `isInfixOf` x
, let num = takeWhile (not . isSpace) x
-- important to use /, and never \ for paths, even on Windows, since then C escapes them
-- and GHC gets all confused
Expand Down
2 changes: 1 addition & 1 deletion src/Development/IDE/GHC/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ diagFromText diagSource sev loc msg = (toNormalizedFilePath $ srcSpanToFilename
Diagnostic
{ _range = srcSpanToRange loc
, _severity = Just sev
, _source = Just diagSource -- not shown in the IDE, but useful for hie-core developers
, _source = Just diagSource -- not shown in the IDE, but useful for ghcide developers
, _message = msg
, _code = Nothing
, _relatedInformation = Nothing
Expand Down
16 changes: 8 additions & 8 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ load(
)

da_haskell_library(
name = "hie-core-testing",
name = "ghcide-testing",
srcs = glob(["src/**/*.hs"]),
hackage_deps = [
"base",
Expand All @@ -23,12 +23,12 @@ da_haskell_library(
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//compiler/hie-core",
"//compiler/ghcide",
],
)

da_haskell_library(
name = "hie-core-test-runfiles",
name = "ghcide-test-runfiles",
srcs = glob(["bazel/**/*.hs"]),
hackage_deps = [
"base",
Expand All @@ -42,9 +42,9 @@ da_haskell_library(
)

da_haskell_test(
name = "hie-core-tests",
name = "ghcide-tests",
srcs = glob(["exe/**/*.hs"]),
data = ["//compiler/hie-core:hie-core-exe"],
data = ["//compiler/ghcide:ghcide-exe"],
hackage_deps = [
"base",
"extra",
Expand All @@ -57,8 +57,8 @@ da_haskell_test(
],
src_strip_prefix = "exe",
deps = [
":hie-core-test-runfiles",
":hie-core-testing",
"//compiler/hie-core",
":ghcide-test-runfiles",
":ghcide-testing",
"//compiler/ghcide",
],
)
8 changes: 4 additions & 4 deletions test/bazel/Development/IDE/Test/Runfiles.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
-- SPDX-License-Identifier: Apache-2.0

module Development.IDE.Test.Runfiles
( locateHieCoreExecutable
( locateGhcideExecutable
) where

import System.FilePath ((</>), FilePath)

import DA.Bazel.Runfiles


locateHieCoreExecutable :: IO FilePath
locateHieCoreExecutable = locateRunfiles hieCoreExePath
locateGhcideExecutable :: IO FilePath
locateGhcideExecutable = locateRunfiles ghcideExePath
where
hieCoreExePath = mainWorkspace </> exe "compiler/hie-core/hie-core-exe"
ghcideExePath = mainWorkspace </> exe "compiler/ghcide/ghcide-exe"
6 changes: 3 additions & 3 deletions test/cabal/Development/IDE/Test/Runfiles.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
-- SPDX-License-Identifier: Apache-2.0

module Development.IDE.Test.Runfiles
( locateHieCoreExecutable
( locateGhcideExecutable
) where

import System.FilePath (FilePath)


locateHieCoreExecutable :: IO FilePath
locateHieCoreExecutable = pure "hie-core"
locateGhcideExecutable :: IO FilePath
locateGhcideExecutable = pure "ghcide"
4 changes: 2 additions & 2 deletions test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ testSession name = testCase name . run

run :: Session a -> IO a
run s = withTempDir $ \dir -> do
hieCoreExe <- locateHieCoreExecutable
let cmd = unwords [hieCoreExe, "--lsp", "--cwd", dir]
ghcideExe <- locateGhcideExecutable
let cmd = unwords [ghcideExe, "--lsp", "--cwd", dir]
-- HIE calls getXgdDirectory which assumes that HOME is set.
-- Only sets HOME if it wasn't already set.
setEnv "HOME" "/homeless-shelter" False
Expand Down

0 comments on commit 5da86c3

Please sign in to comment.