
What I Wish I Knew When Learning Haskell - Cieplak
http://dev.stephendiehl.com/hask/
======
eklavya
Really just learn it.

It's a pity I don't use Haskell at work and yet learning Haskell was the
single most bang for buck exercise I have ever done. "Parallel and Concurrent
Programming in Haskell" is the best resource I have ever read on parallel and
concurrent programming concepts.

Every programmer should learn this language even if they never plan/get to use
it.

~~~
mlthoughts2018
I learned Haskell and used it (and heavily functional Scala) professionally
for about 6 years.

I feel learning Haskell was worthless. It did not teach me anything about
decomposing problems into function units, compositional sequences, pure
functions / immutable data structures, lazy evaluation or asynchronous
programming that I have found useful in modeling solutions to software
problems.

Guarantees from the compiler and use of the type system itself for type
designs like phantom types and type class patterns did not help reduce
behavioral bugs and the slower development cycle of waiting for compilation
(instead of just using occasional unit test runs to check simple safety
conditions in lighter weight dynamically typed languages) was a very
significant cost.

It was no easier, and often much harder, to enable extensibility into systems
designed in Haskell because the constraints of the extensible needs of the
system were only ever learned from changing business circumstances after the
fact and could not be reflected in anticipated up-front design, which is
perhaps the number one need of business software yet is an area where
functional languages are uniquely poorly suited even with veteran, highly
experienced engineers on the team like we had.

In the end, following simple patterns of composition and function purity while
avoiding cookie-cutter design patterns and avoiding use of object / class
constructs is all you need. This is easy to achieve in many imperative
languages while leaving much greater flexibility to choose mutation, treat
safety as a resource to be traded off instead of enforced in all cases, etc.

“Module oriented programming” in Python or C, letting lightweight unit tests
replace heavy reliance on type system patterns, just using simple structs /
namedtuples / dataclasses that posses zero function logic, and creating
imperative APIs around functional-inspired core implementations is strictly
better.

Really, strong adherence to statically typed functional languages with lazy
evaluation is a religious trap. Learning that it’s not all it’s cracked up to
be early in your career is critical for success.

~~~
jmeister
Thank you. This is an important point that deserves to be discussed more.

Would you mind sharing what business domain you were working in? I’ve seen
static FP being used/popular in finance but not much elsewhere.

Also, do you have a favourite language now?

~~~
mlthoughts2018
Jobs that exclusively or almost exclusively used Haskell & Scala: (1) backend
engineering for a large bank (you can likely guess), (2) machine learning at a
large education technology company, (3) machine learning at an ad tech
company.

My favorite two languages are Python and C. There are certain things I like
about Rust, Go and Julia.

I dislike Java and C++ (just personal preference).

I dislike Scala a ton. Really disergonomic and overly complicated.

I like Haskell a lot. Very clean, fun to write, it just doesn’t confer any
serious advantages over other language choices and does suffer from difficult-
to-extend designs in business use cases, but probably very good for academic
work, pure software or research projects. It’s very nice language, I just wish
it wasn’t hyped as a transformational way of thinking or as a panacea for all
the normal annoying problems with business software.

------
shahbaby
A few years ago I accidentally deleted my entire Haskell assignment about 1
day before it was due.

Within a few hours I rebuilt it from scratch.

That's when I realized the power of functional programming. There's no way I
have been able to recover that quickly if I had used an imperative programming
language.

Since that experience I've tried to follow a functional programming style
whenever I can. I've realized that every variable is another state which adds
to the complexity of the code.

~~~
UncleMeat
But it was a programming assignment. Building a thing fast is, outside of very
few situations, not a thing to optimize for. Building something to be
maintained and evolved over time by non rockstars is far far more important,
IMO. Perl is great for ripping through some script quickly but it has problems
for long term maintenance.

~~~
shahbaby
Actually outside of a programming assignment, I think maintenance rather than
speed is precisely why a company would want a functional code base.

How much time is wasted on debugging? Functional programming forces you to
deal with your bugs at a much earlier point of development.

It also forces you to avoid some bad practices just to meet a deadline.

And since you're re-using so many component, you spend much less time with
boiler plate code.

------
kmorgh
I like this reference style of documentation, it tries to give a full overview
of everything there is. Which is usually what I'm looking for. The sections
are also concise.

------
dcl
Great timing. I was just pondering what functional programming language I
should attempt to learn in all my new downtime.

~~~
Random_ernest
I tried to learn FP multiple times by learning haskell. Never clicked, tried
clojure and I was productive after roughly 2 days.

~~~
dan-robertson
As a counterpoint, I picked up (some) haskell pretty quickly.

I read a lot of code and didn’t get bogged down reading explanations of what a
monad is. I also avoided trying to understand too well what the evaluation
semantics of the language were.

When I read code, I focused on looking at the type signatures and
understanding what they meant, then I would stare at the code and try to work
out in my head why those definitions would get those types.

I did this at a time when there were lots of “I wrote a program in Haskell.
Let me explain how it works” blog posts on this site.

I defined some data structures and solved a bunch of project euler problems as
practice

~~~
akegalj
I would second this.

My experience is that people get scarred of so much new terms which get
introduced in Haskell and that could feel overwhelming.

When beginning with Haskell, I would advice to just write code and try to
intuitively understand bits, but not get down into unwrapping things or theory
much. Stay high level and figure out how things interact as you would do in
black box model. Don't open the box, but poke it and see what result you will
get (in other words; just write code and do trial and error).

When you get comfortable with black-box learning then open the box and look
for the details.

------
CJefferson
I feel this might have grown beyond its title.

Picking the point where I gave up, giving me a list of 7 vscode plugins,
without any guidance as to which are more mature, doesnt feel like a thing
anyone would wish to know before they start.

~~~
quchen
I'm pretty sure this (evolving) article has been around well before VSCode's
initial release.

~~~
CJefferson
I'm sure you are right. That is just picking at one thing I will admit, but I
do use vscode, so when I saw a section about how to best use haskell in vscode
i was interested. I'm not interested enough, or as a beginner qualified, to
evaluate 7 options.

~~~
hopia
The IDE problem is still a major pain in Haskell. However, for now there are
just I think 2 main options to choose from, and it's fairly straightforward.
Still, not everything works as expected yet.

We've come a really long way in just the past 3 years with IDE stuff. I
suggest you give it another try if you're still interested in diving into
Haskell.

~~~
pjmlp
Well Leksah seems to still be an option.

------
hopia
I find myself coming back to this for various stuff all the time. It's a great
reference that touches basically everything important for writing real apps
with Haskell.

------
merricksb
Earlier discussions:

[https://news.ycombinator.com/item?id=5546679](https://news.ycombinator.com/item?id=5546679)
(2013)

[https://news.ycombinator.com/item?id=6868303](https://news.ycombinator.com/item?id=6868303)
(2013)

[https://news.ycombinator.com/item?id=7637278](https://news.ycombinator.com/item?id=7637278)
(2014)

[https://news.ycombinator.com/item?id=10209249](https://news.ycombinator.com/item?id=10209249)
(2015)

~~~
dang
[https://news.ycombinator.com/item?id=14226310](https://news.ycombinator.com/item?id=14226310)
(2017)

[https://news.ycombinator.com/item?id=7904987](https://news.ycombinator.com/item?id=7904987)
(2014)

------
harry8
If you're thinking of learning Haskell you should consider the software
written in haskell as an indicator of, well, something.

List all the programs useful for something other than programming a computer
written in haskell:

Xmonad window manager Git annexe Pandoc

What else, let's get the full list. Exclude anything that we can't directly
see or use.

I say, yes! Learn Haskell! Just don't expect to write any useful programs
because they're pretty rare for people to have written when they've doesn't
time learning Haskell.

It is great fun. Do it!

~~~
yakshaving_jgt
Look at all these hundreds of companies who use Haskell to write apparently
useless software.

[https://haskellcosm.com/](https://haskellcosm.com/)

~~~
harry8
Look at the thousands of people who learned Haskell and then also felt
inspired to write a monad tutorial and publish it on the internet. Your search
engine will help to see just how many there are.

Contrast with the number of useful applications you can actually install and
run that are for some purpose that is not programming.

In fact there are more Haskell textbooks you can read than haskell programs
you can install (excluding programs for programming - because that's some
pyramid scheme vibe there).

This tells us something, I didn't even suggest what it tells us. What it
suggests to you is what you thought of.

And fwiw imho pandoc is extremely useful! And Haskell is great fun and worth
your time to learn!

What have you written in haskell that we can use?

~~~
yakshaving_jgt
> What have you written in haskell that we can use?

My three commercial Haskell projects are detailed here[0].

[0]: [https://jezenthomas.com/projects/](https://jezenthomas.com/projects/)

~~~
hopia
Wow, these all look like well crafted. What's your web framework of choice
with Haskell?

~~~
yakshaving_jgt
I build everything with Yesod. I'm sure the others are good too; Servant seems
great. But this is the one I started with, and it's served me very well for
the past few years.

------
w3mmpp
Ah, Haskell, the language I wish used s-expressions...

~~~
lonelappde
[https://www.reddit.com/r/haskell/comments/2u5gac/haskell_wit...](https://www.reddit.com/r/haskell/comments/2u5gac/haskell_with_sexpression_syntax)

------
anaphor
In the section on "Boolean Blindness", I find the example a bit confusing.

I would expect `isNotJust (Just foo)` to equal `False`, not `True`, and vice
versa `isNotJust Nothing` to equal `True`.

The point has some validity (that you should try to encode data into the types
if you can), but the example makes no sense in my opinion.

[http://dev.stephendiehl.com/hask/#boolean-
blindness](http://dev.stephendiehl.com/hask/#boolean-blindness)

~~~
runaway
I thought that was the point of the section- that you may be able to tell
something is wrong with the example, but the compiler can't. Thus by
programming in that fashion you're not taking advantage of the power of the
compiler.

The improved way below where the Just a is unwrapped with a case allows the
compiler to see whether or not x is valid.

~~~
anaphor
Ah ok, that wasn't really clear to me, but that makes way more sense. Clearly
I hadn't had any coffee when I read it earlier.

~~~
lonelappde
That's what these parts were going for:

> Is there anything wrong with the definitions and below

> and why is this not caught in the type system?

And

> ???

on the line you flagged as a bug.

------
privethedge
For those who really want to blow their mind, I suggest learning Coq instead
[https://softwarefoundations.cis.upenn.edu/](https://softwarefoundations.cis.upenn.edu/)

------
spopejoy
It's really aggravating that HN goes against it's own culture so thoroughly
when it comes to Haskell. We're supposed to comment on what TFA says, not lick
our wounds about how Haskell wasn't what we wanted it to be. f you can't
contribute to the thrust of TFA how about creating space to listen to people
who actually know what they're talking about?

Every single piece of hackneyed received wisdom and FUD in here can be easily
countered if you talk to somebody with actual production Haskell experience.
Speaking for myself:

\- I run a startup that has production applications making money for 4 years
now written entirely in Haskell with 6 devs doing nothing but Haskell (as well
as engineers working in JS and our own language, Pact, yes, written in
Haskell).

\- When we need more bandwidth, we work with an all-Haskell consultancy that
itself has no trouble finding work and is very successful in their own right.

\- Before that, I built a group at a major bank writing Haskell code and
getting it out in production, and outperforming Java apps.

\- The tired "eww static types aren't for real business" is opinions
masquerading as "facts". If you are a half-decent engineer in ANY language you
can make your code refactorable for changing requirements. Whining that types
makes that harder just shows your own limitations. Any decent programmer
working in a strongly-typed system leverages types to make code _more_
refactorable in _less_ time with _fewer_ bugs. But hey these are just our
anecdata too. Here's what I'm not doing: spreading FUD about Python or Clojure
or JS, I'm too busy loving what I do.

\- From a hiring perspective, Haskell programmers as a group offer an immense
strategic advantage, and it's mainly _because_ they had to learn Haskell on
the weekend and it wasn't handed to them. That shows passion and grit. I've
built two teams from scratch now in totally different circumstances and it is
simply breezy to find a wide variety of experience levels to craft a team
from; they are by far the best teams I have ever worked with, with zero duds.
The community is strong and excellent and helps each other out as far as job
hunting goes.

Don't blame Haskell if it didn't stick, don't hate on Haskell if you find it
intimidating or pointless. If anything, you should be grateful that there is a
language that is actually different enough to attract a different kind of
programmer, lord knows it's why I'm here: after having jobs in Java, C++,
Perl, Ruby, JS, Visual Basic, Hypercard, you name it, it was nice to see that
there's a different way to do things. It's really fun, there's always more to
learn (not true of every language btw), and finally, it kicks serious ass on
the performance side (as GC/runtime languages go).

------
eska
Not what I expected. Seems to be more of a primer/tutorial.

------
frankmcsherry
Haskell.

~~~
JonCox
[http://learnyouahaskell.com/chapters](http://learnyouahaskell.com/chapters)

------
TazeTSchnitzel
What's up with the formatting on this page? In Firefox for iOS (same rendering
engine as mobile Safari), all lines but the first one in code listings have
4-character indents, and lines use a larger-than-normal font size seemingly at
random.

~~~
lonelappde
That's what mobile Firefox does to most of the web.

~~~
TazeTSchnitzel
Not in my experience.

