Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import scalaz._
  2. import Scalaz._
  3.  
  4. object console extends App {
  5.  
  6. trait Apart[F] {
  7. type T
  8. type G[X]
  9. def apply(f: F): G[T]
  10. }
  11.  
  12. object Apart {
  13. type Aux[FA, A, F[_]] = Apart[FA] { type T = A; type G[X] = F[X] }
  14.  
  15. implicit def af[F[_], A]: Apart[F[A]] = new Apart[F[A]] {
  16. type T = A
  17. type G[X] = F[X]
  18.  
  19. def apply(f: F[A]): G[T] = f
  20. }
  21. }
  22.  
  23. def foo[This, Mo, F[_]](ft: This)
  24. (implicit apart: Apart.Aux[This, Mo, F],
  25. F: Functor[F],
  26. Mo: Monoid[Mo]) = {
  27. F.map(apart(ft))(_ => Mo.zero)
  28. }
  29.  
  30. foo(some(3))
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement