Best hands-on functional programming materials?


#1

I got interested in functional programming when I learned it in Norman Ramsey’s COMP 105- Programming Languages at Tufts, but every time I try to learn Haskell with Learn You A Haskell, I end up running out of steam as Monday approaches, partly because while the book is good at teaching FP concepts, it’s all about the core language and 8 chapters before getting to I/O is a lot. Does anyone have any recommendations for functional programming materials that are hands-on with building something more early on?


#2

I am also interested in people’s thoughts on this. I’m currently looking through Learn Functional Programming With Elixir, but I haven’t gotten far enough to recommend it. I have had good luck with PragProg in general though.


#3

I like this: http://haskellbook.com/

It has lots of exercises.


#4

My first introduction to functional programming was via “Seven Languages in Seven Weeks,” which whet my appetite enough to get me into Learn You A Haskell. It only covers three “days” per language and the whole thing is pretty interactive.

Given you’ve already taken a course with an intro to FP, it sounds like you might be a bit beyond that book but I figure it might be useful for other folks interested in the question :slight_smile:


#5

Seconding @sunahsuh! That whole series is fantastic.


#6

I’m hesitant to recommend Uncle Bob but my intro to FP was the excellent LINQ library in C# plus a rather critical reading the Clean Code (which is IMO a book about empathy that bends itself over backwards to avoid using the word ‘empathy’.

(I don’t consider myself an FP expert but I feel like I really get the core goal.)


#7

My favorite introduction is the Programming Languages course by Dan Grossman. It covers more than just FP, however. I found the comparison/contrast of FP vs other forms very useful. It works in ML and Racket (at least when I was taking it), which are not the most widely used languages, but I still found it incredibly useful for learning FP concepts. In many ways, going to back to simpler languages like ML lets you get all the modern conveniences and hybrid modes out of the way and lets you just focus on FP.

A better “common language” introduction is Functional Programming in Scala by Martin Ordesky. It’s somewhat more “learning Scala, with FP” than “FP in Scala,” but I still found it to be a great foundation if you’re interested in Scala.


#8

If you’re willing to invest in a book, there’s “Haskell: the Craft of Functional Programming” by Simon Thompson. The source code used in the course is distributed on Hackage. It includes many exercises in each chapter, balanced in difficulty levels.

I’m working through this book in my spare time available, and one feature I really like is that you can play with I/O early on, in the form of basic image manipulation (either in a browser or terminal with ASCII art). I like it because the author has provided a high-level framework that let you play with things and get a glimpse of the big picture, but you’re exempted from the gory details about I/O in a pure functional language at the start. Also it doesn’t give you a false sense of understanding about monadic I/O too early. So it seems a balanced way of learning.


#9

This is a pretty good intro using JavaScript:

http://preethikasireddy.me/courses/

#10

Let me recommend two books that I have found useful for understanding the principles.

  1. An Introduction to Functional Programming through Lambda Calculus by Greg Michaelson. You can get a copy from Dover.

This is a book written in the late 80s where you build up an ML-like language from lambda calculus. It has exercises and answers to the exercises. To me personally, it has been the most useful book. I have it near by desk to review concepts now and then.

The greatest strength of the book is that you are learning the concepts instead of learning a specific language. So you are able to apply the same concepts to any functional language that you run into.

  1. I am currently working through “Programming in Haskell” by Graham Hutton. I have found it enjoyable, and it focus on the most useful features of functional programming. Its strength is that it focuses on functional programming concepts rather than monads, so you are learning concepts that can be used in other functional languages or in general purpose languages with limited functional programming support.

I got the book for an Edx course on Haskell. This means that there is already a free course that you can work through if you decide to use the book.


#11

it’s a pay-for book and it focuses exclusively on scala, but alvin alexander’s “functional programming simplified” is spectacular.

aa really over-explains topics, so if you quickly grok some topic, you can just skip ahead, but if it’s more challenging material you won’t find yourself stuck in a ‘draw the rest of the owl’ situation. additionally, his associated blog is full of supplemental material and his further-reading lists in the book are almost always to free resources.

he does spend a lot of time on defining what fp is and what its advantages and drawback are as well, although beyond that it is light on theory.

https://alvinalexander.com/scala/learning-functional-programming-in-scala-book