Search code examples
haskellghcghcup

Installing GHCup vs vanilla GHC for haskell


I want to run Haskell programs(Mostly compiling binaries) but I don't need the other, dare I say, bloat along with the compiler. I just want to install the compiler and start writing code. Just like you would do with something like C/C++. You download gcc/g++, add it to your path and you are ready to go.

Maybe in the future when I get a hang of the language and understand these build systems, then I'll consider using cabal for Haskell, and maybe even CMake for C/C++.

But literally everywhere I have read/researched about this, all suggest installing GHCup and installing a full Haskell distribution. Will I be missing out on something if I just install GHC from their official website and then install the other pieces as I go along?

I know it feels like a yes/no question, But I haven't received any convincing answer anywhere.

Any suggestion/help or links which may help is appreciated.


Solution

  • First of all, GHCup can be used to just install the compiler itself. I would still recommend doing that because it also makes it easy to upgrade the compiler or uninstall everything.

    However, I would also recommend starting to use cabal early. Haskell has a culture of using much more dependencies than most C and C++ projects. Even some basic functionality like arrays require adding dependencies to your project.

    I personally found cabal much simpler than CMake (although I admit I have much more experience with cabal than with CMake). There's no hassle with include and library directories. Many things are managed by cabal automatically. The only remaining difficulty is versioning, but those issues usually only come up in larger projects with many dependencies or if you start using obscure packages (look at the latest upload date and number of downloads if you're not sure).

    GHCup has a good getting started guide and it follows it up with a guide for taking your first steps writing Haskell programs which starts by showing how to evaluate Haskell fragments in the interactive REPL and ends with an introduction to writing your first package with Cabal. I think that is a very good way to start learning Haskell.