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

New to LessWrong?

New Answer
New Comment

4 Answers sorted by

SatvikBeri

Jul 05, 2019

150

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.

davelaing

Jul 05, 2019

80

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.

gilch

Jul 06, 2019

20

[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.

rsaarelm

Jul 05, 2019

20

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

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

5 comments, sorted by Click to highlight new comments since: Today at 2:00 AM

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

Either seems fine but this seems slightly better for longevity

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.

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?

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.