Skip to content

Instantly share code, notes, and snippets.

@marick
Created February 24, 2017 23:55
Show Gist options
  • Save marick/a109720dbf62cd1c0765c3eea7327448 to your computer and use it in GitHub Desktop.
Save marick/a109720dbf62cd1c0765c3eea7327448 to your computer and use it in GitHub Desktop.

What the book covers

The book will begin by teaching the ideas behind the Elm programming language. Elm is one of the breed of languages that compiles down to Javascript. It's also--as far as I know--the friendliest of the static FP languages. Its error messages are superb. Its documentation is good and errs on the side of plain language over jargon. Its emphasis is on the beginner, and the features it provides are well-chosen for that audience. Its command-line interface (the "repl"[^repl]) doesn't present you with mysteries to figure out. It's robust enough that I felt (mostly) confident in using it in two real-world projects--and my confidence was not misplaced.

However. (There's always a "however".)

Elm's laser focus on beginner understandability and usability means that it's missing features or concepts that other static FP languages provide. In particular, it provides extremely limited polymorphism: that feature that lets programmers encode the idea that two things have behavior in common. (In "object land", you get polymorphism from inheritance. In "semi object land", you get it from traits, multimethods, or protocols.)

I'll show what's missing from Elm by describing Purescript. Purescript also compiles to Javascript. It implements important features from the mainstream of static FP. It isn't (yet) as good as Elm at documentation, error messages, or the repl, but the people behind it seem to understand their importance.[^beating] That makes it the gentlest introduction to the more abstract and mathematical parts of static FP.

I may--I'm not sure yet--also cover Idris. Idris takes the whole "static typing" thing up another level. In Elm and Purescript, types exist entirely separately from your code, which computes only on the values of particular types. Idris lets your code compute on types themselves. That is, you can not only have a function that returns integers, you can have a function that returns a type (that could be "integer" or it could be something else).

But even more interesting to me is that Idris is explicitly a language that supports "type-driven development". As a longtime advocate of test-driven development, I am very struck by the similarities between the Idris style and the style of TDD that leans on mock objects.[^goos] Although Idris doesn't have the immediate applicability of Elm and Purescript (with their focus on living within the JavaScript ecosystem), I'm excited by its potential.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment