Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Last active December 15, 2015 01:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuwei-k/5184299 to your computer and use it in GitHub Desktop.
Save xuwei-k/5184299 to your computer and use it in GitHub Desktop.
scala-machines Tee.left

https://github.com/runarorama/scala-machines/blob/46d070a5683c50c3632d0811184cb1cc43ad55c8/src/main/scala/com/clarifi/machines/package.scala#L10

https://github.com/runarorama/scala-machines/blob/46d070a5683c50c3632d0811184cb1cc43ad55c8/src/main/scala/com/clarifi/machines/package.scala#L24

https://github.com/runarorama/scala-machines/blob/46d070a5683c50c3632d0811184cb1cc43ad55c8/src/main/scala/com/clarifi/machines/Tee.scala#L125

https://twitter.com/pocketberserker/status/313441791766564864

type T[-A, -B] = (A => Any) \/ (B => Any)

type Handle[+K, +O] = (O => Any) => K

def left[A]: Handle[T[A, Any], A] = \/.left(_)

↓ package.scalaのtype Tを展開

def left[A]: Handle[(A => Any) \/ (Any => Any), A] = \/.left(_)

Handleを展開。本体もアンダースコアではなく、明示的に引数と型書いた

def left[A]: (A => Any) => ((A => Any) \/ (Any => Any)) = {f: (A => Any) => \/.left(f) }

つまり、 Tee.left は、(A => Any) という関数を受け取って、それを単にleftに包んで返す関数?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment