Skip to content

Instantly share code, notes, and snippets.

@missingfaktor
Created September 15, 2011 22:38
Show Gist options
  • Select an option

  • Save missingfaktor/1220681 to your computer and use it in GitHub Desktop.

Select an option

Save missingfaktor/1220681 to your computer and use it in GitHub Desktop.
Copure and Cojoin
scala> def f[C[_] : Copure : Cojoin, A](a: C[A]) = (a.copure, a.cojoin)
f: [C[_], A](a: C[A])(implicit evidence$1: scalaz.Copure[C], implicit evidence$2
scala> f(Identity(2))
res130: (Int, scalaz.Identity[scalaz.Identity[Int]]) = (2,2)
scala> f(nel(11, 12, 12))
res131: (Int, scalaz.NonEmptyList[scalaz.NonEmptyList[Int]]) = (11,NonEmptyList(
NonEmptyList(11, 12, 12), NonEmptyList(12, 12), NonEmptyList(12)))
scala> f[({type l[A] = (Int, A)})#l, Int]((3, 4))
res137: (Int, (Int, (Int, Int))) = (4,(3,(3,4)))
scala> f(() => 6)
res138: (Int, () => () => Int) = (6,<function0>)
scala> f(9.zipper)
res139: (Int, scalaz.Zipper[scalaz.Zipper[Int]]) = (9,<zipper>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment