pointがmap0という話

Applicativeの型クラスのメソッドに関する話

Functional Programming in Scala の (MEAP v9時点での)Chapter12の209ページにさり気なく以下のように書いてあって

Notice that in this sense unit can be seen as map0, since it's the case of "lifting" where apply is called zero times.

( ゚д゚)ハッ!となったというだけの話。unitだったり、pointだったり、pureだったり、(HaskellMonadだとreturnだったり)色々と別名ありますが。

思いの外衝撃を受けたけれど、その後自分でも、「だからなんなんだろう・・・」とは思いましたが、なんとなくメモ。

以下、Scalazでの例*1。REPLでタブ補完して型表示させたもの*2

scala> val a = Applicative[Option]
a: scalaz.Applicative[Option] = scalaz.std.OptionInstances$$anon$1@243f271f

scala> a.map3
def map3[A, B, C, D](fa: => F[A], fb: => F[B], fc: => F[C])(f: (A, B, C) => D): F[D]   

scala> a.map2
def map2[A, B, C](fa: => F[A], fb: => F[B])(f: (A, B) => C): F[C]   

scala> a.map
def map[A, B](fa: F[A])(f: A => B): F[B]   

scala> a.point
def point[A](a: => A): F[A]   

*1:scalazではmapNはdeprecatedで、applyNとか他のものになってますが https://github.com/scalaz/scalaz/blob/v7.0.0-RC2/core/src/main/scala/scalaz/Apply.scala#L59-L78

*2:見やすいように多少整形してるが