Question

(Sorry, I'm stupid and uneducated, so this is probably a ridiculous question.)

I just started looking at J, and they use the terms "monadic" and "dyadic" for what seems (to me) to be unary and binary operators. Why is this done, and how does it relate to the other place I've heard the term (Haskell)? My guess is they are unrelated homonyms but I'm not sure.

Was it helpful?

Solution

They're unrelated; C. A. McCann points out the etymologies of both.

In any case, the Haskell use, of course, comes from category theory, and is thought to be an independent coining unrelated to the other senses of monad.

Indeed, the J sense of "monadic" dates back to APL, which predates Haskell by a quarter of a century! I think it might predate the category theory usage of the term, too.

OTHER TIPS

They're unrelated except by both deriving from the Greek root for "one". Monadic and dyadic are indeed terms for unary and binary functions. Specifically, they're the Greek-derived equivalents--using -adic instead of -ary. Consider the word "triad", which is also Greek-derived.

Monad in the sense Haskell uses it has an unclear etymology but probably derives from "monoid".

I would encourage sticking with the Latin-derived "n-ary" terms in Haskell, though. All functions in Haskell technically have one argument because of currying, so using the Greek-derived form could produce arbitrary amounts of confusion.

Adicity (or adinity) is an alternative to arity, using Greek numeral roots instead of Latin:

  • niladic/medadic = nullary

  • monadic = unary

  • dyadic = binary

  • triadic = ternary

  • tetradic = quaternary

The various meanings of monad in philosophy, religion, biology, category theory, and functional programming are all derived separately, from its literal denotation of a “unit”. The Haskell term is probably derived from monoid, an algebraic structure equivalent to an additive monad.

No, the J use has nothing to do with the Haskell term. Monadic and dyadic functions are functions of one and two arguments, respectively.

The J terms originate from APL, which is a bit older than Haskell, but I have rarely seen them used like this outside of the APL family.

One example of the use of these terms in a non-APL context is from the book Clean Code, which in the chapter about functions talks about niladic, monadic and dyadic functions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top