Hacker News new | ask | show | jobs
by thinkpad20 2557 days ago
Try using nix instead. Aside from being a fantastic package manager for many languages it’s a godsend for Haskell. The lengthy compilation times with Haskell are one of the not so wonderful parts of the language, but they largely disappear with nix, and the Haskell ecosystem on nix is very well supported, with a large community. Honestly I’ve been developing Haskell for years and have never once used stack. I did use cabal before I discovered nix, but since then I’d hardly dream of using anything else.
4 comments

Thanks for mentioning this. It's a bit hard to get started as the signal:noise ratio is pretty bad. Not because there's bad info out there, per se, but there's a lot of _old_ information out there and it feels hard to (a) stay up to date with what's best and (b) it _seems_ like stuff is still being figured out.

The success of Python, I think, is largely due to pip; the success of Ruby due to bundler; the continued relative success of Java due to maven, etc. And it seems to me Haskell is still figuring this out.

Funny,I tried two years ago to use Nix to have a new onegcc on an old Linux OS, I didn't succeed and finally recompiled gcc from the sources which I found much easier (and better documented) than using Nix.
I didn't know about this, glad I read your comment. Stack/cabal is painful.
For Nix and Haskell in production, I highly recommend this resource:

https://github.com/Gabriel439/haskell-nix

More free resources about learning Haskell:

1. https://github.com/allenleein/brains/blob/master/Zen-of-Func...

2. https://github.com/allenleein/brains/tree/gh-pages/Zen-of-Fu...

Thanks for introducing these. But a question I've been asking is what's the optimum way to start learning Haskell? There're tens of books in the links you mentioned, mostly ranging >400 pages. Obviously it's not efficient to read them all and then decide which was the best. On the other hand, with Haskell evolving all the time, I worry if I start a book I might miss out on some other stuff covered in other books.
Please start from this book:

Haskell Programming From First Principle (The most popular in community)

https://github.com/allenleein/brains/blob/master/Zen-of-Func...

Thanks! I've heard about the authors. Just out of curiosity, how does Learn You a Haskell for Great Good stack up against other resources? (heard a great deal about it here and there.)
Learn You a Haskell for Great Good ends up being a taste thing for me. I didn't really enjoy it and preferred things that stayed in the pure areas of the language longer and tried to demonstrate more abstract math principles using Haskell as a language rather than CS focused data structures and manipulations (I found a discrete logic preprint book from somewhere that was much more enjoyable). Real World Haskell at the time was then a decent reference to trying to do real things.

I would certainly try it but it works kind of the same as gotour: if you want a worked example of a characteristic of the language for a specific thing it's great, if you are trying to get your hands around the language by working through it 'cover to cover' in a sense I felt like I wasn't achieving the level of understanding I hoped for.

LYAH is a good overview of the basics of the language, but it provides little in terms of motivation and exercises. Then again, I learned haskell in it, and it's now my main (non-work) programming language, so it is possible to learn it for great good.
how does nix eliminate compile times???
It doesn’t eliminate them entirely; it’s just very smart about allowing packages to be built exactly once, and having a deterministic output such that it can be determined before a package is built whether a prebuilt version is available. This prebuilt version can either be the result of a previous build on your machine, or on another machine served from a repository.

Of course, there are times when you need to compile yourself, but most slow-to-compile packages, such as Aeson, Lens, Servant or the aforementioned Parsec, and many more on top of that have prebuilt binaries available when built from community snapshots (nixpkgs/nixos). You can even pin your package definitions to guarantee that you’re building something that will have prebuilt versions available. New project build is usually less than a minute or two, sometimes substantially so (anecdotally). Again, not always, but usually.

Looks like it offers precompiled packages:

> Nix lets you download precompiled Hackage packages whereas stack compiles them on your computer the first time you depend on them

Source: https://github.com/Gabriel439/haskell-nix#background