Understanding Combinators

First Reaction

My understanding is that the term “combinators” is not a topic on its own. It generally see it as a modifier term for existing things. So “X combinators” is generally like saying “X where I have thought about how to combine one X with another X pretty carefully.”

For example, a person who uses this term might say elm/parser is a library of “parser combinators”. Their meaning is “these are parsers that can be combined” and they may be using the term (1) just because other people say it or (2) to draw a contrast with parsing systems that may not have functions for fitting parsers together. So parsers like regex or lex/yacc would be distinct from “parser combinators” when talking about parsing techniques in a more formal setting. (In my experience!)

I think things that get this modifier added to them might often have map or map2 or andThen functions, but I do not think “combinator” has a consistently used technical meaning with regards to which of these functions are available (or if there is some other mechanism for combination!)

For example, the Arrowized FRP work here refers to “AFRP combinators” that are pretty different from the typical map2 or andThen approaches. In this case the meaning is roughly “AFRP functions for combining things”.

Better Definition

I think the term “combinators” is generally (always?) used for things embedded within an existing language, so perhaps it is distinguishing between “a language for X” vs “a set of functions for X”. I’m not thinking of counter-examples for this definition right now! Maybe that’s the best definition!

That said, I do not personally find this term super clarifying in casual usage. Maybe in research literature where some researchers make new languages (X) and other researchers make libraries embedded in existing languages (X combinators). Outside of that, it can make things seem more complex than they really are, having the effect of making things less clear and harder to understand. (It’s sort of redundant to say “X combinators” about a library anyway. The fact that it is a library already makes this distinction I think.)

That’s just my perspective on it though. Hope that helps!

9 Likes