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
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 haveVersion 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?
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
haskell-language-server (HLS) is a GHC-oriented implementation of the Language Server Protocol (LSP).
Haskell for Visual Studio Code. This extension adds language support for Haskell, powered by the Haskell Language Server. As almost all features are provided by the server you might find interesting read its documentation.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With