Does the term "monadic" in J have anything to do with its Haskell use?
Asked Answered
I

4

17

(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.

Imitative answered 10/1, 2012 at 17:19 Comment(2)
Not a stupid question; the number of things "monad" is used to mean is quite surprising :)Incongruent
I second ehird... Unique-sounding names many times don't mean the same thing. Just look at how many definitions there are of 'functor'.Makebelieve
I
14

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.

Incongruent answered 10/1, 2012 at 17:23 Comment(3)
I guess the definition of monad you quote is part of the "western philosophical tradition" and used notably by leibniz en.wikipedia.org/wiki/Gottfried_Leibniz#The_monadsMonge
What are you talking about? Haskell predates Lisp, and Lisp predates APL. In fact, Haskell was made just two years after assemblers were invented.Resolved
@trinithis: Are you perhaps confusing Haskell with some other language? Lisp was specified in 1958, APL was developed between 1957 and 1964, but Haskell wasn't started until 1987, and Haskell 1.0 wasn't defined until 1990.Bloodstain
B
20

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.

Berlioz answered 10/1, 2012 at 17:24 Comment(1)
Heh, I love the phrase "arbitrary amounts of confusion".Leroi
I
14

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.

Incongruent answered 10/1, 2012 at 17:23 Comment(3)
I guess the definition of monad you quote is part of the "western philosophical tradition" and used notably by leibniz en.wikipedia.org/wiki/Gottfried_Leibniz#The_monadsMonge
What are you talking about? Haskell predates Lisp, and Lisp predates APL. In fact, Haskell was made just two years after assemblers were invented.Resolved
@trinithis: Are you perhaps confusing Haskell with some other language? Lisp was specified in 1958, APL was developed between 1957 and 1964, but Haskell wasn't started until 1987, and Haskell 1.0 wasn't defined until 1990.Bloodstain
C
13

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.

Chrismatory answered 10/1, 2012 at 22:24 Comment(0)
C
6

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.

Calvinism answered 10/1, 2012 at 17:23 Comment(1)
Another example of monadic and dyadic being used outside APL-specific literature can be found in The Next 700 Programming Languages by Peter Landin (1966). See Section 8. and the appended discussion.Goddess

© 2022 - 2024 — McMap. All rights reserved.