A modern take on the Prelude

Hi thread, I’m surfacing from a 2-day deep-dive into the subject of custom Prelude.

I agree with the rationale from @Wismill on two points:

  • Leave base Prelude be, it’s simple to bash but very hard to fix. Further, everyone will like different preludes (in different applications / contexts) — and an imaginary perfect prelude won’t change that. Haskell should just enable easy switching to alternative preludes. Even better: trivial project-local preludes.
  • The ergonomics of prelude-the-feature is… quite awkward indeed, to put it mildly! I tried hard, but couldn’t get it to work, really — see a writeup in haskell - How to correctly define your 'company' Prelude - Stack Overflow.

I trailed through an assortment of issues on GitHub; and it’s quite difficult to get all of stack build, stack repl & HLS working okay with a project-local Prelude.hs module. I couldn’t do it. As a stop-loss, I’ll instead take the pragmatic approach of saying import MyLocalPrelude everywhere.

The root issue appears to be #10920: ghci can't load local Prelude module · Issues · Glasgow Haskell Compiler / GHC · GitLab already posted twice in the thread. In stack projects, HLS depends on stack repl, which in turn depends on ghci — and the entire “stack” of tooling topples with attempting to use module ‘Prelude’ which is not loaded. It is a blocker, there’s no viable workaround, I didn’t find any way to configure ghc-options or custom ghci-script for stack repl to Just Work.

… Now, to the --prelude-is proposal. Not a huge fan, and I’m not convinced it solves a real issue. The GHC bug is a real issue.

6 Likes