Skip to content

Commit

Permalink
Update the hie-bios commit SHA (digital-asset#1825)
Browse files Browse the repository at this point in the history
* Update the hie-bios commit SHA

* Also update the SHA in our bazel WORKSPACE

* Update the hash too

* Tutorial for Emacs integration

* Update hie-bios patch
  • Loading branch information
Shayne Fletcher authored Jun 22, 2019
1 parent e63b012 commit c8e7af5
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 7 deletions.
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ hazel_repositories(
hazel_github_external(
"mpickering",
"hie-bios",
"9f9fe00591c429c410475349560252ca7e622f1b",
"0f9cf9ed897ed1faf1a36dadc06ba9bb3c525f8553da30bee0615294f4d00b00",
"8427e424a83c2f3d60bdd26c02478c00d2189a73",
"c593ff871f31200e37a3c24c09da314d0ee41a8486defe7af91ac55a26efdc1e",
patch_args = ["-p1"],
patches = ["@com_github_digital_asset_daml//bazel_tools:haskell-hie-bios.patch"],
),
Expand Down
12 changes: 8 additions & 4 deletions bazel_tools/haskell-hie-bios.patch
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
diff --git a/src/HIE/Bios/Cradle.hs b/src/HIE/Bios/Cradle.hs
index 8d7705f..cb9d2cc 100644
index 291a706..7a37977 100644
--- a/src/HIE/Bios/Cradle.hs
+++ b/src/HIE/Bios/Cradle.hs
@@ -112,7 +112,7 @@ cabalCradle wdir mc = do
@@ -125,10 +125,10 @@ cabalCradle wdir mc = do
}

cabalWrapper :: String
-cabalWrapper = $(embedStringFile "wrappers/cabal")
+cabalWrapper = $(embedStringFile "external/haskell_hie__bios/wrappers/cabal")

cabalWrapperBat :: String
-cabalWrapperBat = $(embedStringFile "wrappers/cabal.bat")
+cabalWrapperBat = $(embedStringFile "external/haskell_hie__bios/wrappers/cabal.bat")

cabalAction :: FilePath -> Maybe String -> FilePath -> IO (ExitCode, String, [String])
cabalAction work_dir mc _fp = do
@@ -162,7 +162,7 @@ stackCradle wdir =
@@ -179,7 +179,7 @@ stackCradle wdir =

-- Same wrapper works as with cabal
stackWrapper :: String
Expand All @@ -20,7 +24,7 @@ index 8d7705f..cb9d2cc 100644

stackAction :: FilePath -> FilePath -> IO (ExitCode, String, [String])
stackAction work_dir fp = do
@@ -211,7 +211,7 @@ rulesHaskellCradle wdir = do
@@ -228,7 +228,7 @@ rulesHaskellCradle wdir = do


bazelCommand :: String
Expand Down
50 changes: 50 additions & 0 deletions compiler/hie-core/hie-core-in-emacs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# How to get `hie-core` working in Emacs

First step is to install required Emacs packages. If you don't already have Melpa config stuff in your `.emacs`, put this stanza at the top.
```
;;Melpa packages support
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
(when no-ssl
(warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)
;; Remember : to avoid package-not-found errors, refresh the package
;; database now and then with M-x package-refresh-contents.
```

When this is in your `.emacs` and it's been evaluated, `M-x package-refresh-contents` to get the package database downloaded and then `M-x package-list-packages` to display the available packages. Click on a package to install it. You'll need to install the following packages.
- `lsp-haskell`
- `lsp-ui`
- `flycheck`
- `yasnippet`

When done with this, add the following lines to your `.emacs` :
```
;; lsp-haskell
(require 'lsp)
(require 'lsp-haskell)
(require 'yasnippet)
(add-hook 'haskell-mode-hook #'lsp)
(setq lsp-haskell-process-path-hie "hie-core")
(setq lsp-haskell-process-args-hie '())
(setq lsp-log-io t) ;; Inspect comms betweeen lsp client/server
```

Next stop is to build `hie-core`. In the `daml` repository, navigate to `//compiler/hie-core` and invoked `stack build`. This will install the `hie-core` executable into a location along the lines of `/Users/shaynefletcher/project/daml.git/compiler/hie-core/.stack-work/install/x86_64-osx/nightly-2019-05-20/8.6.5/bin/hie-core`. You want to get this executable in your `$PATH`. I achieved this by `ln -s /Users/shaynefletcher/project/daml.git/compiler/hie-core/.stack-work/install/x86_64-osx/nightly-2019-05-20/8.6.5/bin/hie-core ~/.local/bin/hie-core` (because `~/.local/bin` is put in my `PATH` in my `~/.bashrc`).

Time to test things out. It's important to note that you for this to work, your programs need to be compiled with the same compiler used to build `hie-core`. For testing, I've been using the `ghc-lib-gen` target of the `ghc-lib` project). Navigate to the root of `ghc-lib`, create an `hie.yaml` file with contents `cradle: {cabal: {component: "exe:ghc-lib-gen"}}`. Invoke `cabal new-configure -w ~/.stack/programs/~/.stack/programs/x86_64-osx/ghc-8.6.5/bin/ghc` (this is the `ghc` used by `stack` to build `hie-core` - consult `//compiler/hie-core/stack.yaml` to help work out what you should write here). This last step will create a file `cabal.project.local` with contents pointing `cabal` to use the desired `ghc`. You can build `ghc-lib-gen` from the `ghc-lib` directory with the command `cabal new-build` as you like.

After the last step, you should be all set. Open `ghc-lib/ghc-lib-gen/src/Main.hs` in an Emacs buffer and, for example, hover should bring up type/definition info.
2 changes: 1 addition & 1 deletion compiler/hie-core/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ extra-deps:
- .
- haskell-lsp-types
- git: https://github.com/mpickering/hie-bios.git
commit: 9f9fe00591c429c410475349560252ca7e622f1b
commit: 8427e424a83c2f3d60bdd26c02478c00d2189a73
nix:
packages: [zlib]

0 comments on commit c8e7af5

Please sign in to comment.