(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.
What is a Monad? A monad is an algebraic structure in category theory, and in Haskell it is used to describe computations as sequences of steps, and to handle side effects such as state and IO. Monads are abstract, and they have many useful concrete instances. Monads provide a way to structure a program.
monad, (from Greek monas “unit”), an elementary individual substance that reflects the order of the world and from which material properties are derived. The term was first used by the Pythagoreans as the name of the beginning number of a series, from which all following numbers derived.
A monadic function is a function with a single argument, written to its right. It is one of three possible function valences; the other two are dyadic and niladic. The term prefix function is used outside of APL to describe APL's monadic function syntax.
Lists are a fundamental part of Haskell, and we've used them extensively before getting to this chapter. The novel insight is that the list type is a monad too! As monads, lists are used to model nondeterministic computations which may return an arbitrary number of results.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With