简体   繁体   English

J中的术语“monadic”是否与Haskell的使用有关?

[英]Does the term “monadic” in J have anything to do with its Haskell use?

(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. 我刚开始看J,他们使用术语“monadic”和“dyadic”来表示(对我来说)是一元和二元运算符。 Why is this done, and how does it relate to the other place I've heard the term (Haskell)? 为什么要这样做,它与我听到的那个地方(Haskell)有什么关系呢? My guess is they are unrelated homonyms but I'm not sure. 我的猜测是他们是无关的同音异义词,但我不确定。

They're unrelated except by both deriving from the Greek root for "one". 它们是无关的,除非两者都来自希腊词根“一”。 Monadic and dyadic are indeed terms for unary and binary functions. Monadic和dyadic确实是一元和二元函数的术语。 Specifically, they're the Greek-derived equivalents--using -adic instead of -ary . 具体来说,它们是希腊语派生的等价物 - 使用-adic而不是-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. 不过,我会鼓励在Haskell中坚持使用源自拉丁语的“n-ary”术语。 All functions in Haskell technically have one argument because of currying, so using the Greek-derived form could produce arbitrary amounts of confusion. 由于currying,Haskell中的所有函数在技术上都有一个参数,因此使用希腊语派生的形式会产生任意数量的混淆。

They're unrelated; 他们是无关的; CA McCann points out the etymologies of both. CA McCann指出了两者的词源。

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 . 无论如何,Haskell的使用当然来自范畴理论,被认为是与monad其他意义无关的独立创造。

Indeed, the J sense of "monadic" dates back to APL, which predates Haskell by a quarter of a century! 事实上,J“monadic”的感觉可以追溯到APL,它早于Haskell四分之一世纪! I think it might predate the category theory usage of the term, too. 我认为它也可能早于该术语的范畴理论用法。

Adicity (or adinity ) is an alternative to arity , using Greek numeral roots instead of Latin: Adicity (或adinity )是arity的替代品,使用希腊数字根而不是拉丁语:

  • niladic/medadic = nullary niladic / medadic = nullary

  • monadic = unary monadic =一元

  • 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”. monad在哲学,宗教,生物学,范畴论和函数式编程中的各种含义都是从“单位”的字面表示中分别得出的。 The Haskell term is probably derived from monoid , an algebraic structure equivalent to an additive monad. Haskell项可能来源于monoid ,一种等效于加性monad的代数结构。

No, the J use has nothing to do with the Haskell term. 不,J的使用与Haskell术语无关。 Monadic and dyadic functions are functions of one and two arguments, respectively. Monadic和dadadic函数分别是一个和两个参数的函数。

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. J术语源自APL,它比Haskell稍早,但我很少看到它们在APL族之外使用。

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. 在非APL环境中使用这些术语的一个例子来自清洁代码一书,该代码在关于函数的章节中讨论了关于niladic,monadic和dyadic函数的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM