Guest User

Untitled

a guest
Aug 16th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. trait PipeFunction[A, B]
  2. class NullPipeFunction[A, B] extends PipeFunction[A, B]
  3.  
  4. trait Pipe[S, E]
  5.  
  6. class Pipeline[S, E, T[S, E]] extends Pipe[S, E] {
  7. def add[F](pipe: Pipe[E, F]): T[S, F] =
  8. throw new UnsupportedOperationException()
  9. }
  10.  
  11. class FluentPipeline[S, E, T[S, E]] extends Pipeline[S, E, T] {
  12. def filter1[F](f: PipeFunction[E, F]): T[S, F] =
  13. throw new UnsupportedOperationException()
  14.  
  15. def filter2[F](f: PipeFunction[E, F]): T[S, F] =
  16. throw new UnsupportedOperationException()
  17. }
  18.  
  19. class GremlinPipeline[S, E] extends FluentPipeline[S, E, GremlinPipeline]
  20.  
  21. object Test {
  22. def main(args: Array[String]) {
  23. val long2Float = new NullPipeFunction[Long, Float]
  24. val float2Double = new NullPipeFunction[Float, Double]
  25.  
  26. val int2Long = new GremlinPipeline[Int, Long]
  27. val int2Float = int2Long.filter1(long2Float) //GremlinPipeline[Int, Float] properly inferred
  28. val int2Double = int2Float.filter2(float2Double) //GremlinPipelin[Int, Double] properly inferred
  29.  
  30. //GremlinPipeline[Int, Double] properly inferred
  31. val int2Double2 = new GremlinPipeline[Int, Long].filter1(long2Float).filter2(float2Double)
  32. }
  33. }
Add Comment
Please, Sign In to add comment