What are good resources for learning functional programming?

post by Matt Goldenberg (mr-hire) · 2019-07-04T01:22:05.876Z · LW · GW · 5 comments

This is a question post.

Contents

  Answers
    15 SatvikBeri
    8 davelaing
    2 gilch
    2 rsaarelm
None
5 comments

I'm looking to use the 3 Books Technique [LW · GW] to learn functional programming. Does anyone have any "What", "Why' or "How" resources for functional programming (or resources that don't fit the categories?)

Answers

answer by SatvikBeri · 2019-07-05T06:06:01.526Z · LW(p) · GW(p)

My favorite book, by far, is Functional Programming in Scala. This book has you derive most of the concepts from scratch, to the point where even complex abstractions feel like obvious consequences of things you've already built.

If you want something more Haskell-focused, a good choice is Programming in Haskell.

answer by davelaing · 2019-07-05T02:03:41.962Z · LW(p) · GW(p)

Most of my resources are Haskell related.

If you are new to programming, I usually recommend "How to Design Programs". It is the only text I know of that seems to teach people how to design programs, rather than expecting that they'll work it out themselves based on writing code for a few years.

For a starting point for programmers, I usually recommend the Spring 2013 version of CIS194 - "Introduction to Haskell" - from UPenn. The material is good quality and it has great homework. Our meetup group relayed the lectures, so there are videos available here.

"Introduction to Functional Programming using Haskell (2nd Edition)" by Richard Bird is also really good if you want to get some hands on experience with using equational reasoning to prove things about programs, or to partially synthesize programs from their specifications. It is aimed at undergraduates, but is more advanced than CIS194.

"Parallel and Concurrent Programming in Haskell" by Simon Marlow is great for doing more applied work with Haskell, but I'd do CIS194 first.

I currently work for a group that runs free FP courses. There is an introductory course here that can be done on your own but is challenging - we only cover a subset of the content when we actually run the course. There is an applied course here that is easier to tackle without an instructor, but requires that you're comfortable with the concepts from what we teach during the introductory course.

answer by gilch · 2019-07-06T22:06:15.756Z · LW(p) · GW(p)

[Disclaimer: I haven't finished it yet]

Haskell Programming From First Principles: Pure functional programming without fear or frustration by Christopher Allen and Julie Moronuki.

The preface explains how Chris wrote it in the process of teaching Julie, an absolute beginner to computer programming, and they refined the material together using that feedback process.

The result I found more approachable than Learn You a Haskell for Great Good, which I had read earlier.

This probably falls in the "How" category. It has exercises. But there is some exposition on the "What" and "Why" as well. If you work though it you should have achieved basic proficiency with the language, which should help you understand any ML-style language, or exposition using similar notation.

answer by rsaarelm · 2019-07-05T09:06:17.032Z · LW(p) · GW(p)

Very non-comprehensive, but from things I've read and liked:

How: What I Wish I Knew When Learning Haskell

What: Chris Okasaki, Purely Functional Data Structures

Why: SICP

comment by Kenny · 2019-07-17T00:06:24.965Z · LW(p) · GW(p)

I second SICP as a good 'why' book for this.

5 comments

Comments sorted by top scores.

comment by Matt Goldenberg (mr-hire) · 2019-07-04T01:56:32.531Z · LW(p) · GW(p)

I used to ask questions like this on the open thread, and am curious if people think it belongs there instead.

Replies from: Raemon
comment by Raemon · 2019-07-04T03:52:19.327Z · LW(p) · GW(p)

Either seems fine but this seems slightly better for longevity

comment by Vladimir_Nesov · 2019-07-05T05:55:38.906Z · LW(p) · GW(p)

My impression is that there are no books that even jointly give a reasonable selection of what you'd need to master the main ideas in (typed) functional programming. Most of this stuff is in papers.

Replies from: Kenny
comment by Kenny · 2019-07-16T23:21:13.189Z · LW(p) · GW(p)

Master as in 'physics' (or 'mathematics') versus 'engineering'? I'd be really surprised if the 'engineering' of functional programming wasn't well-covered by existing books. What's one main idea that you don't think could be mastered in any book? Or, if any one idea might be covered by some book, what are all the main ideas that you don't think any one book covers?

comment by Kenny · 2019-07-17T00:36:03.289Z · LW(p) · GW(p)

I'm a 'lowly practitioner' and I've only used functional programming languages a modest amount in my professional experience. Most of the other answers seem to be, mostly, focusing on newer functional programming languages, of which Haskell seems to be the 'coolest' one currently, and that's not one I've learned beyond very cursory 'skimming'.

One metric by which I'm judging this question as particularly great is that it bugs me – I'm not sure how to answer it, even 'in principle', for at least the 'what' and 'how' books. (For the 'why' book, I think SICP should be a great resource even tho it's not strictly functional programming.)

What would a good 'what' book or resource for functional programming look like? One reason I'm confused about this is that I'd expect a good 'what' resource to be specific to an individual programming language, but then would it still be a good 'what' resource for functional programming in general?

Similarly for any 'how' resource – what would one look like that isn't tied to a specific language? Or not tied to any language at all? I'm probably 'typically-minding' this, even from the perspective of an experienced programmer, but I'm struggling to think of enough 'how' material specific to functional programming to fill a book-sized resource. Working Effectively with Legacy Code is a great 'how' book (covering exactly what the title implies), but I can't think of, off the top of my head, how many 'how' questions there could be for functional programming specifically.