14

I've decided to start with Haskell and bumped into an unfamiliar ecosystem. I've wrote down my current conclusions in short and long version (by now I realise the issue I had is probably temporal and won't apply in the future and realise that below text might be a bad fit for SO).

What I want to know now specifically is

  • Does the setup I'm describing makes sense to veterans?
  • Why is GHC 8.6.5 is the recommend version, and what's wrong with 8.8.2?

Short version:

If this is your first contact with Haskell and you want to install Haskell (ghccup, ghc, cabal-install, stack) and a dev environment made up of Visual Studio Code, Haskell Language Server plugin and HIE. Make sure that stack new as per (https://docs.haskellstack.org/en/stable/README/#start-your-new-project) and the HIE you are installing are all resolving to the same version of GHC that was installed by ghcup.

Long version:

Hi Haskellers!

I'm sharing my foray into Haskell and hopefully save someone else from a rookie mistake or two. Like all sensible people I've asked google how to install haskell, which led me to the following page https://www.haskell.org/platform/ (I'm on macOS 10.13.6). I've Downloaded ghcup as per recommendation which in turn installed ghc 8.6.5 & cabal-install 3.0.0.0. Both are the recommended versions according to ghcup. I was able to ghcup list, ghcup list -t all and everything looked good. stack was next as recommended. The procedure is straight-forward and after stack did everything it needs to do I stack --version which told me that I have
Version 2.1.3, Git revision 0fa51b9925decd937e4a993ad90cb686f88fa282 (7739 commits) x86_64 hpack-0.31.2.

Next part of stack documentation got me into trouble https://docs.haskellstack.org/en/stable/README/#start-your-new-project. Specifically stack new my-project for the uninitiated will setup a new project based on what is called a resolver. What I didn't knew or care to at this point, is that it by default would use the 15.2 version of the resolver (most recent as I write this) to setup an isolated environment with "the batteries included" for the project (please correct me on any wrong assumption/terminology). What I could have not known is that resolver 15.2 "expects" to find ghc 8.8.2 and if it does not find it, it does the sensible thing and installs it. I intuitevely understand the problem – that this is addressing – and I move on (this is before I've found https://github.com/commercialhaskell/lts-haskell#readme).

Moving on to IDE, google leads me to the haskell-language-server which is not ready for the prime time. Next best thing is haskell-ide-engine which can be considered a part of the whole that haskell-language-server will be. Being naive and satisfied with the experience so far, I build hie from source as I'm neither interested in doing anything with nix at this point or figuring out what a Visual Studio Code DevContainer is. The build is succesfull, so far I've installed HIE, ghcup, ghc, cabal-install, visual studio code package Haskell Language Server and I'm ready to start learning Haskell. Except HIE refused to work :/.

What went wrong?

  • ghcup installed ghc 8.6.5 on my machine
  • stack new my-project by default used the most recent resolver 15.2 which installed ghc 8.8.2 (isolated to the project)
  • HIE build itself (?) by looking at the ghc installed by ghcup which is 8.6.5 The result is a mismatch between version the version HIE is build against and the version that was setup by stack new my-project. Once I better understood what parts were involved it was easy to google for solution and forced me to thoroughly read the docs. The fault is all mine for not paying better attention to the docs I was reading. However, I wasn't prepared to have to figure out the nuances of the small but crucial part of the ecosystem.

I do realise that the entire situation is entirely self inflicted and I could've started with learning the language right after installing GHC and firing up GHCI. I'm wondering if I took the wrong turn or if this is how most people start?

Update 25th of July 2020

Haskell Language Server is now much easier to install, have a look at this post and the video at the end of it. https://mpickering.github.io/ide/posts/2020-07-10-ghc-libdir.html

rusln
  • 1,284
  • 8
  • 10
  • 2
    This looks like a pretty reasonable experience. It doesn't seem like you did anything wrong; rather, the documentation and the tooling are the main culprits here. `stack` for just leaving you wondering why it's installing stuff on its own, and the Haskell IDE ecosystem for being a mess. – Li-yao Xia Mar 02 '20 at 20:27
  • 1
    Voting to reopen. While I can kind of see where the close votes are coming from, there is an underlying answerable question here (what had gone wrong with the OP's HIE setup), as well as an useful answer by a HIE contributor. It might be of some use to edit the question to make that more visible. – duplode Mar 03 '20 at 11:15
  • I agree, my thoughts were all over the place. I'm unsure of how to extract my "core" insight into a simple question. What I'm trying to get to is some sort of 'Hey, you are comfortable with VS Code, and know nothing of Haskell. This is what you should do to get the setup right before diving into the docs!'. There is this essential dependency 'GHC version' that must match, but, following the "happy path" from https://www.haskell.org/platform/ -> https://docs.haskellstack.org/en/stable/README/ -> https://github.com/haskell/haskell-ide-engine will not get you to a working setup. – rusln Mar 03 '20 at 21:28

1 Answers1

9

Does the setup I'm describing makes sense to veterans?

The haskell ecosystem may seem strange at first (well maybe it is!) and to start learning the language basics maybe the best option is what you comment at end (the chosen one by the data61 course, for example).

I think the key of the problem is most haskell tooling is coupled to a specific version of the unique haskell compiler, moreover if the tool has to parse, format or typecheck haskell source code (like editors and ides need to do).

However, as one of the collaborators of haskell-ide-engine i would like to make the tool installation and usage as smooth for beginners as possible. The installation could be done using stack and cabal and, afaik it is not automatic.

You have to do a stack install.hs latest to install hie using the last ghc version supported by the tool, currently ghc-8.8.2. You also can install an specific version with stack install.hs hie-${version} f.e stack install.hs hie-8.6.5.

If you uses cabal to install hie, the install program looks for ghc versions in $PATH and cabal-hie-install latest installs the latest supported version found. Maybe did you use cabal to install hie?

You can install several versions of hie and each installation generates several executables: for example hie itself, hie-8.6 and hie-8.6.5 and a hie-wrapper that analyzes your project and choose the more appropiate hie version, if available.

Do not hesitate in suggest how the process could be improved. There are some issues about:

jneira
  • 944
  • 10
  • 18
  • Thank you for your time, I appreciate your insightful feedback! I realise that "Next best thing is haskell-ide-engine…" sounds wrong and I didn't intend for anything that I wrote to be a critique but honest thoughts as I encountered things for the first time (I was determined to figure it out either way). Thank you for pointing me to https://github.com/haskell/haskell-ide-engine/issues/1383, I'll read up on the current affairs and see if I can contribute. – rusln Mar 03 '20 at 21:35
  • in my case both ghcup and stack report 8.8.3, but when I try to compile on macos i get__1] rejecting: hie-bios-0.4.0 (conflict: haskell-ide-engine => hie-bios>=0.5 && <0.6.0) – tofutim May 10 '20 at 05:42
  • @tofutim i've just try it in windows and it works, maybe it worths open an issue in the issue tracker? https://github.com/haskell/haskell-ide-engine/issues Feel free to cc me in the issue with at jneira – jneira May 13 '20 at 06:52