top | item 16348422

An opinionated guide to Haskell

260 points| kryptiskt | 8 years ago |lexi-lambda.github.io | reply

92 comments

order
[+] resoluteteeth|8 years ago|reply
I've tried messing around with haskell a few times, but the biggest problem I have is the tooling.

I just tried to get haskell set up a few days ago and I couldn't get it working with either vscode or Idea. I also couldn't get ihaskell (jupyter notebook) installed successfully.

I might give it another shot based on these instructions, but the fact that pretty much every program seems to make different assumptions about whether you're using cabal or stack and how you have them set up is really annoying. I assume if you are really knowledgeable about this tools it's not that bad, but as a haskell beginner they are completely impenetrable. (Even just the yaml files used by stack seem completely incomprehensible compared to the formats used by most languages' build tools.)

Considering that the language itself has a pretty steep learning curve, it's really frustrating wasting several hours just trying to get the haskell environment set up without success and not even getting the point of being able to try to actually use it.

I've had a pretty bad opinion of the Ocaml and F# tooling in the past, but the haskell tooling is just so, so much worse. (F# seems to have gotten to a point where the tooling if you can just use .net core, although it gets horrible again if you then need to also use mono at the same time so you can use the interpreter.)

It's especially bad if you compare it to something like rust where cargo works so well it's actually in itself a reason to use rust.

[+] danharaj|8 years ago|reply
Haskell + Nix is the best environment I've ever used for any development. My go-to project manager is this script in the reflex-platform, which is a bit poorly named (it will change eventually), because it's actually an environment for doing general cross-platform full stack Haskell development: https://github.com/reflex-frp/reflex-platform/blob/develop/p...

The learning curve is definitely, shamelessly high. We've been slowly polishing it to make it easy for complete beginners to fully up-to-speed on a project in minutes, but it's a lot of work that happens mostly on weekends.

Watch this space!

[+] cyclinghacker|8 years ago|reply
My advice would be start with stack and hpack, and remain with your editor or IDE of choice to start with. Learning any new language is difficult enough without having to also deal with a different workflow.

This is my recipe for starting with haskell and intellij: - install stack, run `stack new helloworld simple-hpack` - make sure it builds: `cd helloworld && stack test --exec helloworld` - install https://github.com/rikvdkleij/intellij-haskell and follow the `Getting started' guide

[+] chillee|8 years ago|reply
Ocaml tooling has actually gotten substantially better over the past year or two.

VSCode as an editor that just works.

Opam for package management

JBuilder for managing builds.

Stdlib situation is still kind of a mess, but I think Base (which is just a stripped down Core) solves a lot of the current issues.

[+] embwbam|8 years ago|reply
It takes a while for the Haskell community to reach consensus. Stack is definitely recommended by almost everyone for both beginners and production projects. It is used on every project I’ve run in to lately. Sure there are different ways to configure it, but these days there’s really one way to get started. Just download stack, make a new project, and start coding
[+] platz|8 years ago|reply
ihaskell is a somewhat fragile project briding several disparate ecosystems/languages. I'm not really sure the value-add is there yet; in any case it is not a tool for beginners or the preferred method to get feedback from your programs.

Haskell proper is pretty turn-key these days with stack.

Stay away from edgelord / niche projects.

Stay away from most of the IDE tooling, including ghc-mod. You don't need to be fighting the tooling when starting. The repl and "ghcid" should be all you need (though I grant it takes some learning to use these as effectively if you're used to an IDE- you will learn with experience).

Just use the "ghcid" cli tool to get compile errors and feedback. It is rock solid.

https://github.com/ndmitchell/ghcid

Your experience will be much smoother.

It takes a bit getting used to if you're used to an IDE, but with Haskell it's usually a better to go for a multi-terminal/repl kind of setup

[+] emmelaich|8 years ago|reply
Same with me. I download some code (or git clone) from an article or gist or somewhere which looks cool.

I'd estimate 80% of the time I fail to compile. Typical reasons are errors from Cabal, stack is wrong version, things like that.

If it was C or Python or even Rust I'd forge ahead and make it work. But with Haskell's tooling I'm too far out of my depth to bother.

[+] joeblau|8 years ago|reply
What operating system are you running on? I paid for and downloaded Haskell For Mac[1] and it's been a great dev experience so far. The IDE is similar to Xcode (I'm an iOS developer) and the REPL is great for trying stuff out.

[1] - http://haskellformac.com

[+] vaibhavsagar|8 years ago|reply
I help maintain IHaskell and I'm sorry to hear you had trouble setting it up. If you'd like to open an issue on the IHaskell repo I can try to help you troubleshoot your install.
[+] xfer|8 years ago|reply
How is Ocaml tooling worse than rust? Merlin is very powerful and it gives me everything i want from an editor integration.

I still can't get point-at type to work in emacs/vim for rust reliably(macros make it even worse).

Haskell tooling is good enough(i haven't worked on big projects, so maybe it doesn't scale) now with intero if you use emacs.

[+] allenleee|8 years ago|reply
For people who wanna learn Haskell:

1. Don't touch Haskell platform. Install Stack.

If you did, Uninstall it.

https://mail.haskell.org/pipermail/haskell-cafe/2011-March/0...

Why? It is considered harmful

https://mail.haskell.org/pipermail/haskell-community/2015-Se...

2. Install Stack:

https://haskell-lang.org/get-started/osx

If you do not wish to install these dependencies, you may use a virtual machine instead

https://github.com/data61/fp-course/blob/master/ops/README.m...

3. Learning resources:

https://github.com/allenleein/brains/projects/9

[+] aaronchall|8 years ago|reply
I consulted with one of the co-organizers of the Haskell meetup here in NYC, and while he seems to have a nuanced view that is anti-stack for professional Haskellers, he also recommends stack for new people.

I'm thinking the consensus is that this is good advice.

[+] Cieplak|8 years ago|reply
A lot of people use Atom, but I think emacs + intero is currently the best Haskell tooling. I use it with spacemacs. Has everything I would need from an IDE, including highlighting errors on the fly, auto completion, jump to definition, auto formatting. It’s no intellij, but I’ll take Haskell’s type safety over that any day of the week, and twice on Sunday.

http://commercialhaskell.github.io/intero/

[+] s4vi0r|8 years ago|reply
+1, emacs+intero is the way to go.

Emacs in general is highly underrated due to years of RSI/muh loading time shitflinging. Evil mode is by far the most complete vim emulation out there, and other than JS pretty much every language I write has been a more enjoyable/easy experience on Emacs than it was on vim or st3.

[+] csmiller|8 years ago|reply
Emacs + Intero is absolutely the way to go, I switched to Emacs to learn Haskell and have loved it ever since.
[+] marcosdumay|8 years ago|reply
There's a while that I can't find intero in melpa.org anymore. Do you know if it moved?
[+] dmitriid|8 years ago|reply
> There was a time when cabal-install had a (warranted) reputation for being nearly impossible to use and regularly creating dependency hell

> You almost certainly do not want to use stack install.

> The .cabal file is, ultimately, what is used to build your project, but modern versions of stack generate projects that use hpack, which uses an alternate configuration file, the package.yaml file, to generate the .cabal file. This can get a little bit confusing, since it means you have three configuration files in your project

> Frankly, I think the UX around this is terrible.

This goes to show that no amount of static typing can save you from implementing badly-designed software.

[+] Devac|8 years ago|reply
> This goes to show that no amount of static typing can save you from implementing badly-designed software.

Sure, but that's like saying "you can die to cancer even if you drive around in a Volvo."

[+] audiolion|8 years ago|reply
Wow, I wish this existed when I was wprking with Haskell a few years ago. This is a compendium of useful information. I really love how Haskell makes me think and code in an entirely different way. It is fun, and I hope the language continues to grow.
[+] resoluteteeth|8 years ago|reply
OK, I am trying to install haskell again using the instructions given in this guide.

I removed my existing stack installation and my .stack directory, installed stack again, created a new stack project and then ran the recommended command in the guide to install ghc-mod and related tools: "stack build -j 8 --copy-compiler-tool ghc-mod hoogle weeder".

I get an error:

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for ghc-mod-5.8.0.0: Cabal-2.0.1.1 from stack configuration does not match >=1.18 && <1.25 (latest matching version is 1.24.2.0)

...etc.

Can someone explain what's causing this?

[+] s4vi0r|8 years ago|reply
Cabal version too high. Did you have a pre existing cabal installation independent of stack or something?
[+] cauterize|8 years ago|reply
This is really great. I'd love to see a follow up covering other topics. Such as testing (with hedgehog), modeling SQL, etc. Or -- anything that helps open up the world to see how Haskell is a beautiful language to build on.
[+] dvddgld|8 years ago|reply
Learning Haskell is one of those two weeks things that’s been on my interests list for a long time, but will likely stay there for awhile yet.

Though, if anyone has got any high-quality quick resources handy that’d be appreciated!

[+] farresito|8 years ago|reply
Haskell is so far the language that has blown my mind the most, and it's not even close. Admittedly, I haven't learned that many (esoteric) languages (I found Prolog very peculiar, for example), but if you have never done any functional programming before, Haskell will (hopefully) blow your mind as well.
[+] pdpi|8 years ago|reply
If you’re in it for the two-week thing rather than the long term, “learn you a Haskell for great good” is a good choice. Not terribly informative if your goal is writing large applications, but pretty good introduction to the mindset that goes with writing haskell
[+] latte|8 years ago|reply
How good is the static analysis tooling (IDE / editor plugins) for Haskell?

Given Haskell's powerful type system, I imagine that it must be possible to see warnings, hints, autocompletion and other early feedback about the code in the editor before compilation, like in Java, Kotlin etc. or even better - is that the case?

[+] preordained|8 years ago|reply
Maybe things have changed, but not a couple years ago when I was working with Haskell. No IDE story at all, which is just a crying shame when you think about the kind of refactoring and powerful features you could support. The fact that vim or other text editors were typically what was used was just odd and a waste IMO...like having a rocket propulsion system strapped to a Huffy.
[+] tathougies|8 years ago|reply
I use emacs + intern and it’s great. Type errors are underlined immediately, warnings and lint messages are marked. Half the time I let the compiler write the code by using ghc placeholders and playing type golf
[+] jadbox|8 years ago|reply
When I look at many modern Haskel guides, they all seem to recommend adding all these extensions/sugar into your code. If these things are so common to use, why doesn't Haskel adopt them into core?
[+] tikhonj|8 years ago|reply
The standardization process is really slow and conservative, and making it faster is not a priority for anyone because—at least at the moment—GHC is the only meaningful compiler, so the standard wouldn't be doing more than explicitly recording how GHC's extensions work.
[+] whateveracct|8 years ago|reply
LANGUAGE pragmas just end up being like imports. It felt weird to me at first but by now it’s just as natural.

If you want to have some on by default, you can set that up easily in your cabal file.

[+] badwebsite|8 years ago|reply
Haskell is a standardized language that moves very slowly. Some of the extensions may be integrated into Haskell2020.