
I'm currently doing some refactoring of the GHC sources, which involves moving definitions between modules. As a sanity check I want to compile often, so if I've broken anything (or have inadvertently created circular imports) I can find out quickly. I'm currently using ./hadrian/build -j but I really don't need to build libraries or a stage 2 compiler. I tried looking over `./hadrian/build --help`, but I'm not confident that I understand what's there. My best guess is ./hadrian/build -j stage0:lib:ghc Would that accomplish my goal? Norman

My recommendation: ./hadrian/ghci. The first time you run it, it may spin for a little while, but it will eventually deliver you to a GHCi prompt, with all of GHC loaded. (You can e.g. `:type splitTyConApp_maybe`, after `import GHC.Core.Type`.) At that point, :reload will be your dear friend. That's what I do when I'm doing e.g. module reorganization and care much more about "does it compile" than "does it work". Richard
On Jan 24, 2022, at 5:02 PM, Norman Ramsey
wrote: I'm currently doing some refactoring of the GHC sources, which involves moving definitions between modules. As a sanity check I want to compile often, so if I've broken anything (or have inadvertently created circular imports) I can find out quickly. I'm currently using
./hadrian/build -j
but I really don't need to build libraries or a stage 2 compiler. I tried looking over `./hadrian/build --help`, but I'm not confident that I understand what's there. My best guess is
./hadrian/build -j stage0:lib:ghc
Would that accomplish my goal?
Norman
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

My recommendation: ./hadrian/ghci. The first time you run it, it may spin for a little while, but it will eventually deliver you to a GHCi prompt, with all of GHC loaded. (You can e.g. `:type splitTyConApp_maybe`, after `import GHC.Core.Type`.) At that point, :reload will be your dear friend. That's what I do when I'm doing e.g. module reorganization and care much more about "does it compile" than "does it work".
Cool! Supposing I wanted to run just a little code that uses the GHC API. Would there be a way to load the Prelude and similar things into that GHCi, so it could know about Bool and IO and such things? Norman

On Jan 25, 2022, at 2:15 PM, Norman Ramsey
wrote: Cool! Supposing I wanted to run just a little code that uses the GHC API. Would there be a way to load the Prelude and similar things into that GHCi, so it could know about Bool and IO and such things?
The GHCi that runs is your system's GHCi, so it has access to everything installed in your bootstrap GHC. However, I don't see a connection between your second sentence and your last sentence: that is, the GHCi will certainly know about Bool and IO, but I don't see how that helps with the GHC API. I have no idea how you would use the GHC API in this mode. My advice would be to use this trick to get quick feedback about compilation, and then once GHC compiles, use other more well-worn techniques to build it and test your application. Richard

My recommendation: ./hadrian/ghci.
Richard, this suggestion has been so useful that I would like to follow it up. I'm about to change a type definition. This change may wreak havoc in many parts of GHC, and this is exactly what I want: I'm looking for type-error messages that will tell me what code I need to fix. I do this work in emacs using `M-x compile` and `next-error`. The key property is that `next-error` requires just a couple of keystrokes (C-x `) and it makes Emacs take me to the relevant source-code location quickly. But telling `M-x compile` to run `./hadrian/build` is quite slow. Is there a way to leverage `./hadrian/ghci` for this workflow? Norman

On Fri, Jan 28, 2022 at 11:52:00AM -0500, Norman Ramsey wrote:
My recommendation: ./hadrian/ghci.
I'm about to change a type definition. This change may wreak havoc in many parts of GHC, and this is exactly what I want: I'm looking for type-error messages that will tell me what code I need to fix. I do this work in emacs using `M-x compile` and `next-error`. The key property is that `next-error` requires just a couple of keystrokes (C-x `) and it makes Emacs take me to the relevant source-code location quickly.
But telling `M-x compile` to run `./hadrian/build` is quite slow. Is there a way to leverage `./hadrian/ghci` for this workflow?
Are you familiar with dante-mode for Emacs? It relies on ghci behind the scenes to point out type errors in Emacs Haskell buffers. You might find it convenient even if only for this single-purpose use case. I wrote up how I use dante: http://h2.jaguarpaw.co.uk/posts/how-i-use-dante/ You will have to `M-x customize-group dante` to set the GHCi path to `.../hadrian/ghci`. Tom

This is the typical use case for a language server.
I have haskell-language-server installed and use it extensively on GHC
for stuff like jump to definition and immediate compilation feedback.
There's also "jump to next error" if you want that.
Installation was pretty trivial for me, just flipping this switch in my
local ghc.nix clone:
https://github.com/alpmestan/ghc.nix/blob/88acad6229300d8917ad226a64de80aa49...
You will probably have to install an LSP plugin for emacs first.
The hour or so I invested on initial setup has probably saved me several
days already.
Sebastian
------ Originalnachricht ------
Von: "Norman Ramsey"
My recommendation: ./hadrian/ghci.
Richard, this suggestion has been so useful that I would like to follow it up.
I'm about to change a type definition. This change may wreak havoc in many parts of GHC, and this is exactly what I want: I'm looking for type-error messages that will tell me what code I need to fix. I do this work in emacs using `M-x compile` and `next-error`. The key property is that `next-error` requires just a couple of keystrokes (C-x `) and it makes Emacs take me to the relevant source-code location quickly.
But telling `M-x compile` to run `./hadrian/build` is quite slow. Is there a way to leverage `./hadrian/ghci` for this workflow?
Norman _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

This is the typical use case for a language server. I have haskell-language-server installed and use it extensively on GHC for stuff like jump to definition and immediate compilation feedback.
I would *love* to be doing this. I have had HLS installed on my machine for months, and have been using with Emacs. But to say I have trouble getting it work as advertised is an understatement. For example, on the module I'm trying to diagnose, I'm getting just one error message, on the first line: Data.Binary.Get.runGet at position 1844: not enough bytes
There's also "jump to next error" if you want that.
I can't find it using either "C-h f" or using the list of keybindings at https://emacs-lsp.github.io/lsp-mode/page/keybindings/. I think it might be supported by flycheck, but "C-x `" simply says "No more Flycheck errors." In general, my experience is "sometimes it works and sometimes it doesn't." Even for things as simple as "M-." (find definition). If you know of any resources on using HLS with GHC, I'd love to be directed. For example, when Emacs asks if I really want to watch circa 5,000 directories, do I say "yes"?
The hour or so I invested on initial setup has probably saved me several days already.
I am **so eager** to get there. But definitely not there yet. Norman

The Binary runGet issue usually means that your build tree is out of date. It's probably worth deleting and building from scratch again.

The Binary runGet issue usually means that your build tree is out of date. It's probably worth deleting and building from scratch again.
Brilliant! Definitely working much better! And @Sebastian I start to see the productivity gains. Remove all redundant imports with one click! Norman

Great! Glad I could help.
FWIW, if I have strange HLS bugs, I mostly restart it (if it had worked
before) or delete .hie-bios, where HLS stores its build results.
HLS builds the same stuff as what hadrian/ghci needs to build. The
former puts it in .hie-bios, the latter in ... .hadrian-ghci? Not sure.
Anyway, if HLS behaves strangely, try deleting its build root.
Sebastian
------ Originalnachricht ------
Von: "Norman Ramsey"
The Binary runGet issue usually means that your build tree is out of date. It's probably worth deleting and building from scratch again.
Brilliant! Definitely working much better!
And @Sebastian I start to see the productivity gains. Remove all redundant imports with one click!
Norman _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

The Binary runGet issue usually means that your build tree is out of date. It's probably worth deleting and building from scratch again.
For those who may come after me: if ./hadrian/ghci barfs with a Binary runGet issue, the build tree that needs to be deleted is `.hadrian_ghci`, not `_build`. NR

[Finding the locations of compiler errors after a change]
This is the typical use case for a language server. I have haskell-language-server installed and use it extensively on GHC for stuff like jump to definition and immediate compilation feedback.
There's also "jump to next error" if you want that.
I've now reached the stage where I make a change in a module, and it compiles, but the change causes a compiler error in another module far away. Is there a way to ask the language server to jump to an error in another module? (I'm using Emacs lsp-mode, and all I've found for errors is `flycheck-next-error`, which is not ideal. But if the language server can monitor the whole project, I'll get some Emacs help on how to get the info there.) Norman
participants (5)
-
Norman Ramsey
-
Richard Eisenberg
-
Sam Derbyshire
-
Sebastian Graf
-
Tom Ellis