Hacker News new | comments | show | ask | jobs | submit login
Advice for Haskell beginners (2017) (haskellforall.com)
186 points by sridca 88 days ago | hide | past | web | favorite | 59 comments



Addenda (relevant to community musings today):

Be aware that as a small and very distributed community, the Haskell world has less power to eject bad actors than more centrally managed and resourced projects have (e.g., Golang and Rust have much more structural power to moderate). Awful and abusive people exist in the community, and it's best to just start blocking and ignoring folks who disrespect you.

The amazing thing about the Haskell community is that knowledge is very well distributed throughout the community these days. The culture, influenced by academia, strongly values writing and publishing ideas rather than sharing them orally or in the workplace. This means that if you're interested in learning, there are a ton of places and ways to do it.

If you're looking for good initial connections to folks who are respectful, well informed, and unlikely to expose you to some of the frustrating cabals in the community, I've got a few recommendations

1. Gabriel Gonzales (this is his blog, and he's @GabrielG439 on twitter)

2. Chris Martin of TypeClasses. I'd also list his partner in crime Julie Moronuki, but her social media interaction is reduced these days. These two focus on helping programmers get up to speed with haskell from a variety of starting points, and they care more about functional programming than haskell specifics.

3. Patrick Thompson of Github (@importantshock on Twitter). A fantastically skilled person who will link you to a network of amazing Haskell folks who do stuff in a positively next-generational way.

Two people who are adjacent to the Haskell community and incredibly interesting, but probably can't answer direct questions for you. Worth a follow.

1. Dr. Edwin Brady, creator of the Idris language. He's widely respected, humble, and has a beautiful vision for how humans and computers should interact to write programs.

2. Dr. Bodil Stokke (@bodil on twitter). Bodil is not so much a Haskell person these days, but she's got a phenomenal breadth of knowledge and always has interesting things to talk about in the FP space. Worth a follow if you're on that platform.

I suppose you can ask me for help too, but I'm certainly not as competent as these folks.


Can second all these suggestions. Also, from my experience all the Haskell events I've been to have been incredibly welcoming and positive, whilst I'm aware there are a tiny subset of abusive people out there, I've never met them nor met anyone who would tolerate them.

Shoutout if you're in the SF area, BayHac (https://wiki.haskell.org/BayHac2018), a yearly unconference/hackathon is incredibly fun, and also there are (roughly) bi-monthly Haskell meetups (https://www.meetup.com/Bay-Area-Haskell-Users-Group/) in SF which are great fun (disclaimer: I co-organise the meetups - find me @Nick_enGB).


> Addenda (relevant to community musings today): [...] Awful and abusive people exist in the community

Are you referring to people saying negative things about Learn You A Haskell?


No. I'm referring to people like Tony Morris. There are more folks I could name, but I think they're less obvious.

Scala's community essentially began to adopt a thinly-coded code of conduct that said, "Don't be like Tony Morris he literally runs people out of the scala community" it got so bad. He continues to be unrepentant and uses his influence to fan a slow but very distressing conflict between the Cabal community and the Stack developer community.

As for LYAH, it's a decent book. It's got its problems (in some cases it does obnoxious and useless things like make fun of overweight people).


https://twitter.com/dibblego/status/1032041025240358912

What's his (Tony Morris') point? Is he putting on a show or is that for real?


He's always like this. He may be physically incapable of accepting censure.

He blocked me when he read my prior comment.


The guy has serious issues, I was shocked at how toxic he gets at the drop of a hat. I was browsing a discussion on the Haskell subreddit and he was incredibly nasty, literally zero good faith given or assumed of others. Technical opinions aside, I would never want him involved with a project I'm participating in. He fails the only rule I care about: don't be an asshole.


I don't have any personal knowledge of it but I've heard that the code of conduct you're referencing was actually created and weaponized by certain sociopath-types to eject Tony from his own open source library in a hostile takeover.

And not that it excuses his behavior, but I also seem to recall Tony suffering from some very severe back injuries accompanied by chronic pain.

(Not to white knight a person I'm barely aware of but your description seems pretty one-sided based on what I've seen)


> I don't have any personal knowledge of it but I've heard that the code of conduct you're referencing was actually created and weaponized by certain sociopath-types to eject Tony from his own open source library in a hostile takeover.

Not that I agree with this narrative, because AFAICT it wasn't true, but even if it were? Good. That's the power and mechanism open source working as intended. If you're a burden to the project, you're cast off. And Tony is an insufferable burden. The code is free, and owned by the group.

The fact that he expected "ownership" of a project set up with a leadership committee is a good example of the kind of silly behavior I'm talking about.

> And not that it excuses his behavior, but I also seem to recall Tony suffering from some very severe back injuries accompanied by chronic pain.

I was around for two public declarations of dramatic self harm. I'm told there are more. And I hope he finds a way to deal with these problems, they're serious and can be life threatening. I don't wish violence on him.

But I want him to stop making communities worse with his senseless negativity and hostile communications. If he has problems in his life that impair his ability to interact in this fashion, we should not enable his abusive behavior out of charity. That's actually disrespectful, and while it may benefit Tony in the short term, in the long term he finds himself forced out of communities that no longer can or will bear the weight of his presence.

> your description seems pretty one-sided based on what I've seen

It's certainly one sided: it's my side. I for one ran into him a lot. It seems like he took special delight in demanding I take his impromptu "quizzes" in Scala and he'd hound me ceaselessly until I did. His ultimate goal was to prove I was "not a functional programmer." He's been cut off by a lot of longtime members of the FP community for a reason.


Defending Tony Morris isn't really the hill I want to die on, seeing as how I have no experience with the situation and I unfollowed him a long time ago to get away from the negativity myself. I was just repeating what I heard some prominent people mention here and there, but I guess I got a bit too caught up in playing devil's advocate.

Thanks for sharing your unfortunate experience, and I agree that health problems or things like that should not be an excuse to behave poorly. Take care.


Absolutely not. The code of conduct was created to help produce a welcoming and supportive community, and if Tony being kicked out for being neither welcoming nor supportive counts as 'weaponizing', then that's a very strange view. I've met many of the people who were involved in this and they are amongst the nicest, friendliest, accepting people you could meet, and about as far from 'sociopath' as you can imagine.

This idea of a hostile takeover and such is a figment of Tony's imagination and a deliberate distraction equivalent to Trump's referring to the Mueller investigation as a witch hunt.


I haven't met any of the people involved but I recall other folks saying the CoC was being used inappropriately

https://twitter.com/puffnfresh/status/519887926327390209


We're actually conflating two separate but correlated events here, as a few folks in that thread have later acknowledged.

Most folks agree that Tony should be off the project. The problem of one overzealous person trying to get Tony to shut up is a separate and regrettable decision on his part. CoCs act to protect people from behavior like Tony's, not to be a cudgel. AFAIK, it's faced subsequent edits to improve that.

It's unfortunate that Tony's become so incapable of modulating his behavior in public that he forces these issues. It's doubly regrettable that folks associated with the same projects he has contributed to could not handle the unusual situation with more grace and poise.


No, they are (unfortunately) referring to a (small but vocal) group of people who seem to get enjoyment out of insulting, upsetting and demeaning other people, particularly beginners.


> Dr. Bodil Stokke (@bodil on twitter)

Speaking of "frustrating cabals" just be prepared for a hefty infusion of socialist ideology[1] into your stream with this follow. Might get a bit grating if that's not your politics, your family is currently fleeing Venezuela, you don't enjoy irony in the contrast with her interleaving pictures of her expensive toys and housekeeper-maintained upper-class London apartments paid for by her FinTech job, etc. (inb4 "there's no such thing as ethical consumption under capitalism").

[1]: Unfortunately this is pretty common in PL Twitter and is a downside to the "influenced by academia" notion you bring up (https://theotherlifenow.com/occupations-and-their-ideologies...)


Please follow the site guidelines in cases like this. There's a reason they ask you not to introduce extraneous flamebait.

https://news.ycombinator.com/newsguidelines.html


These kinds of comments are why I was very careful to pick who I was mentioning. Bodil is a very public figure and more than capable of taking care of herself. Hopefully, I (and more importantly she) won't regret that decision.

But anytime you make a list of "here are people who are helpful and won't demand much but courtesy in return" in the Haskell community folks like you pop up demanding I mention your favorite guy like he's relevant or necessary. Go write your own list if you want your gab.ai fp follow list.


I think otherwise your list is great. And I think if you're of a similar political persuasion as her, Bodil's a good choice as well. I enjoyed her content for a time but the constant drip of misandry and political hypocrisy got to me after a while. YMMV, maybe I'm just fragile.

I don't have a "gab.ai fp follow list" because I don't like mixing politics with programming precisely because it devolves into the kind of tribalism on display here.

I'm sorry you took offense to "these kinds of comments" but I don't see how you're entitled to put Tony Morris on blast for your experiences but I can't share my own (admittedly passive) experience with Bodil?


For someone who doesn't like to mix politics and tech, you're the singular voice having that conversation here while everyone else seems indifferent. Maybe you do actually like to do it.

Perhaps follow your own claimed ethics and don't pollute this conversation with politics? It's not like my list wasn't quite diverse in the political spectrum.


I also don't like hearing about religion while I'm trying to listen about programming - guess that makes me a religious person too?


Why are you bringing it up then?

I'm doing my best to avoid concrete assertions about your personality or preferences. But I can't help but notice that you're acting in a manner contrary to your stated preferences.


I think this (short) article had a lot of good points, though I do take minor issue with one bit:

> Some people learn Haskell with the expectation that they will achieve some sort of programming enlightenment or nirvana. You will be disappointed if you bring these unrealistic expectations to the language.

While I have not achieved any sort of nirvana, I do believe that learning Haskell has "enlightened" me insofar as I now look at programming in a fundamentally different way. I put a much greater emphasis on writing many small functions, I use types wherever possible (and type hints too, since Python is my primary language), and I avoid side-effects when I can. All of these things I do because Haskell taught me just how powerful simplicity can be.

I also learned about different ways to conceptualize the relationships between data, and I learned about laziness (something I'd never heard of before then). Haskell has a lot to offer for people who come from an imperative background.

> Haskell is not an achievement to unlock or a trophy to be won because learning is a never-ending process and not a finish line.

While you can never "finish" learning, you can set milestones to mark your achievement. Comprehending some of Haskell's features (both the basics and the advanced ones) are perfectly acceptable milestones by which to track progress. I don't think that's a bad thing.

---

That said, overall the article is very good. I agree that newcomers should write small programs, get their hands dirty, and learn to really use the basic features of the language firsthand before moving on to more advanced things. (And especially I agree that new users should avoid typeclasses at first, or even at second.)


Regarding `avoid side-effects`, the amount of side-effects that are required for a typical real problem solving code base is quite reasonably measurable. For example, the number of network calls, DB calls, FileSystem read/writes are are measurable. Have you been able to reduce the `side-effects` significantly or have just become more aware of it?

When we started using ExpressJS (coming away from Java), there was a tremendous change. As soon as you begin to code in Javascript (say from Java/Ruby/Python world), async hits you. There is no escaping it. And the programmer faces a tax (every time when implementing async/await or generators), his/her awareness about side-effects (deliberately generalizing IO as side-effects) and they tend to be more careful with it.


Avoiding side effects sounds like something someone new to Haskell would say. Haskell in no way avoids side effects. Actually I'd say it embraces them by introducing special semantics just for them! What it does do is encourage you to move side effects to the "edge" of your code base and produce a more clean separation between pure & non-pure code. This is incredibly valuable for testing and overall correctness.


Right, and this is what I actually meant. It's not that side-effects disappear, but rather that I try not to litter my code with them. I avoid them in the sense that I don't embrace a side-effect-heavy style of coding, as I did with my imperative code prior to learning Haskell.

Perhaps I could have worded that better. Sorry for the confusion.


> Have you been able to reduce the `side-effects` significantly or have just become more aware of it?

Yes, sorry, I think I didn't explain myself very well.

Prior to learning Haskell and embracing The Way, my code was fairly covered in side-effects. I was a relatively junior programmer at this point (many years of experience because I started young, but few years of real education). Side-effects were just, you know, a thing that happened because they were "the easy way".

After learning Haskell, I became much more conscious of side-effects. I realized that a lot of things I used to do could be done without side-effects, mostly by writing better functions and thinking more deliberately about how to eschew the side-effects.

That said, it's not like they're gone. It's just that I'm much more careful about them. I "avoid" them in that I do my best not to include them, but if there's a genuine use for them then that's fine. However, I have taken to naming my functions better to reflect their side-effecting nature, and I try to move the side-effecting functions to places that make more logical sense (instead of just wherever).


Came here to say the same re: nirvana. Maybe keep moderate expectations, but yeah it did open something up for me.

I think the truth is somewhere between "programming nirvana" and "no more null pointers and undefined functions".


> While I have not achieved any sort of nirvana, I do believe that learning Haskell has "enlightened" me insofar as I now look at programming in a fundamentally different way

Can I ask whether Haskell in particular led to this enlightenment, or if functional programming is the underlying concept responsible? I've been considering learning Julia for fun and am wondering if it would impart some of the same benefits.


I think functional programming in general is part of it, for sure.

That said, my first success with functional programming was actually with Racket. Racket is great for learning (in my opinion), but the "lessons" Racket had to offer weren't really solidified for me until I moved to Haskell. At that point, things really started to click.

That could be due to any number of things, though. However, certain concepts (e.g., laziness, typeclasses) are more Haskell-specific (or at least are not common among all functional languages).


Here, you're basically re-iterating the same point the author made. Some of it was written implicitly while the rest is laid out in a way that induces the mentality you're after, yet, without making any promises based on perceived benefits.


I started learning Haskell by working on a proof of concept for a relational language. The big advantage, I think, was I _didn't_ try to do anything fancy with monads or typeclasses. I was just interesting in expressing functions, and that got me fairly fluent in that subset of Haskell.

It definitely helped later when I started working on a language myself, and now needed to write a parser and do a lot of transformations using uniplate.

My biggest piece of advice for beginners trying to do anything more complicated that requires dependencies is to use stack[1] and set up a skeleton project.

Set up your stack.yml file with the latest nightly (hack on nightlies, release on LTS) and then visit stackage[2] to see docs _completely in sync with the versions you're using_. You should just be able to add dependencies you need to package.yml.

That gets you a fairly stable environment where things will actually do what you expect, which eliminates a big source of confusion and frustration.

[1]: https://docs.haskellstack.org/en/stable/README/ [2]: https://www.stackage.org/nightly-2018-08-21


Cabal newbuild is quite nice.

For newbs stack is fine. But I genuinely question any serious code base that needs stack. Genuine cabal hell hasn’t existed since around 2010. And the mini purgatory that some people call hell is impossivle with cabal new build.

My perspective is perhaps biased, but I also am comaintainer of widely used libraries used literally everywhere plus I’ve done commercial and recreation and research flavors haskell dev for over a decade, currently at a fortune 10ish sized company.

Though zooming out: these days I tell learners they should try everything out, and revisit various tools as their mastery grows.

For industrial / large prjects that want pinned deps, I’ve seen folks happy with the mafia build tool or even going full nix for end to end os level reproducible build and config.

My main issue with workflows like those centered around stack is that I’ve seen a lot of folks just not think about library versions and deps as part of their library/application foot print. And this has various consequences in how they engineer and upgrade their own libraries and applications.


I wish they had stack when I started. I ended up in Cabal hell and left. Now I love Racket and find that it really was a better functional landing place, but I hit to many walls early on. I am glad these are getting fixed.


If you're not on a purely intellctual trip, my advice is to first get a feeling for the language before trying to understand everything. Every widely used concept arises out a necessity and not out of thin air. Don't read all the monad-tutorial first. It's hard to understand not only why this abstract nonesense is useful, but even what it "is" (assuming you have no serious math background)! The interesting thing is that the concept arise naturally if you spend some time tinkering with haskell. The Functor arises almost instantly!


Sounds like the Haskell Pyramid https://patrickmn.com/software/the-haskell-pyramid


> Haskell is not an achievement to unlock or a trophy to be won because learning is a never-ending process and not a finish line.

Haskell aside, I think this is a fantastic point regardless of whatever it is you're learning. There's always so much more to learn and having this mindset makes it a lot easier to do so.


Reminds me a bit of the quote:

"A classic is something everybody wants to have read, but no one wants to read." --Mark Twain


I have skimmed all the famous books so far on haskell. But the best learning resource to me so far has been the UPenn course [0] because of the quick coding and feedback loop in the browser. Also, the beginning assignments involve visualizations, which is always good to check if you are doing things right or wrong.

0. https://www.seas.upenn.edu/~cis194/fall16/


I read through part of the "Learn you a Haskell" book that was posted here yesterday, and started getting really excited to use this beautiful language.

And then I started looking into ways to use it for making games and was... disappointed. Maybe I've been spoiled by the vibrancy of JavaScript's ecosystem, but I hoped to find a library for simply rendering existing meshes with existing materials and the closest I found was a library of base OpenGL hooks. Add onto that the lack of half-decent UI libraries (on the web you can use Elm, which is similar but different) and it feels like the only thing Haskell is practical for is headless data-processing, which is a shame.


Not exactly games, but The Haskell School Of Expression by Paul Hudak is targeted at multimedia work in Haskell. I haven't read it, but if that's what you want to work on, it might be worth checking out.


I'll check it out. Mainly what I'm interested in is doing world simulation in Haskell; it seems like it would be a really interesting language for that. But that kind of thing isn't very useful without a decent way to visualize and interact with it.


My conclusion about using Haskell to make games and device drivers¹ is: don't.

Even if the ecosystem changed and some great libraries appeared since I last tried, the language itself is a bad match for those domains. Lazyness is great everywhere, except when it works against you, and the garbage collector will assure you notice it.

1 - On my case, userspace drivers. I'm still open to userspace filesystems (I have on on my TODO list, if I ever get there), but device controlling implies on some harder real time requirements.


I can see why it would be bad for drivers, but why games? Functional programming has started to become popular in that space lately, and for good reason


https://github.com/Gabriel439/post-rfc/blob/master/sotu.md Game programming Rating: Immature

> Haskell is a garbage collected language, so Haskell is more appropriate for the scripting / logic layer of a game but not suitable manipulating a large object graph or for implementing a high-performance game engine due to the risk of introducing perceptible pauses due to GC pauses. Also, for simple games you can realistically use Haskell for the entire stack.


Haskell state keeping is either fast or convenient, not both. Timing has several issues, not only GC pauses, but the entire functional paradigm was not created for real time. Lazyness adds up fast if you keep passing stuff through clock ticks.

None of that is a showstopper. But I'd rather use a language that doesn't suffer from fundamental drawbacks on the domain I will work.

That said, Haskell is very promising for AI. If I ever get to that game again, I'm writing the main loop in Rust with an asynchronous AI in Haskell.


Games are all about keeping the user in the 'flow'. Humans are really good at picking up on unpredictable timing.

Action games are thus fundamentally hard-real-time systems.


My thinking was to have a top game loop that "ticks", and then passes the current game state + the time delta to a pure function which returns the new game state, which gets stored. Is the concern that Haskell's lazy-evaluation might lead to a higher level of variance in frame-rate than another language?


Right.

One technique used for writing games to run on GC'd runtimes is to avoid allocations entirely in the game loop. With a lot of work, you can preallocate everything you're going to need and just modify it as you run.

This technique is not a good match for Haskell's primary design principle of avoiding mutable state.


To be clear, I'm not aiming to build the next Call of Duty; these days you can get pretty far building a medium-sized 3D game out of unoptimized JavaScript running on a web page. The GC optimization you mention is interesting to learn of, but probably irrelevant for the kinds of things I would be doing. Does that change your assessment of Haskell for this purpose?


That depends on how large is your state. The GHC GC is normally fast, but gets slower the more objects you keep around. Lazyness can severely increase the number of such objects.

If your game has real time dynamics, it's not worth it. If it's some turn-based one without animation, it's not a problem.


Good to know, thanks for the info


Alternative opinion (self plug):

https://gilmi.me/blog/post/2018/07/24/pfgames


You can use Haskell to do the things Elm does (and more, like deploying to mobile). Checkout reflex and obelisk:

http://docs.reflex-frp.org/en/latest/ https://github.com/obsidiansystems/obelisk


My advice for Haskell("monad") beginners would be to try to re-implement the("a") State monad by yourself without using any libraries. It helped me understand that monads are nothing more than just function composition.


At this very moment I am checking the applicative and monad laws for the state applicative / monad discussed in Hutton's book. Wish me luck ...


I like "Functors, Applicatives, and Monads in Pictures" [0] as a gentle introduction to the concepts. Same revelation as yours, but through a different vehicle.

[0] http://adit.io/posts/2013-04-17-functors,_applicatives,_and_...


https://github.com/MostlyAdequate/mostly-adequate-guide is also didactic but goes into more details, and is not Haskell-specific (IIRC functors, map and so forth are all defined in JavaScript)


With regard to yesterday's exhumation of LYAH I'd like to point out typeclasses.com which I just discovered on r/haskell through this announcement: https://joyofhaskell.com/posts/2018-08-06-announcement.html.


Can anyone recommend a similar article for Rust?




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: