Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

TransformCSFunc.java

By: PthariensFlame on Feb 4th, 2012  |  syntax: Java  |  size: 2.14 KB  |  views: 77  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package fmlist;
  2.  
  3. import fj.F;
  4. import fj.F2;
  5. import fj.F3;
  6. import fj.F4;
  7. import fj.F5;
  8. import fj.Monoid;
  9.  
  10. abstract class TransformCSFunc<A, B, S> {
  11.  
  12.     abstract <M> M f(Monoid<M> m, F<B, M> f, A e, F2<M, S, M> c, S i);
  13.  
  14.     <M> F<S, M> f(Monoid<M> m, F<B, M> f, A e, F2<M, S, M> c) {
  15.         final TransformCSFunc<A, B, S> self = this;
  16.         final Monoid<M> m_ = m;
  17.         final F<B, M> f_ = f;
  18.         final A e_ = e;
  19.         final F2<M, S, M> c_ = c;
  20.         return new F<S, M>() {
  21.  
  22.             @Override
  23.             public M f(S a) {
  24.                 return self.f(m_, f_, e_, c_, a);
  25.             }
  26.         };
  27.     }
  28.  
  29.     <M> F2<F2<M, S, M>, S, M> f(Monoid<M> m, F<B, M> f, A e) {
  30.         final TransformCSFunc<A, B, S> self = this;
  31.         final Monoid<M> m_ = m;
  32.         final F<B, M> f_ = f;
  33.         final A e_ = e;
  34.         return new F2<F2<M, S, M>, S, M>() {
  35.  
  36.             @Override
  37.             public M f(F2<M, S, M> a, S b) {
  38.                 return self.f(m_, f_, e_, a, b);
  39.             }
  40.         };
  41.     }
  42.  
  43.     <M> F3<A, F2<M, S, M>, S, M> f(Monoid<M> m, F<B, M> f) {
  44.         final TransformCSFunc<A, B, S> self = this;
  45.         final Monoid<M> m_ = m;
  46.         final F<B, M> f_ = f;
  47.         return new F3<A, F2<M, S, M>, S, M>() {
  48.  
  49.             @Override
  50.             public M f(A a, F2<M, S, M> b, S c) {
  51.                 return self.f(m_, f_, a, b, c);
  52.             }
  53.         };
  54.     }
  55.  
  56.     <M> F4<F<B, M>, A, F2<M, S, M>, S, M> f(Monoid<M> m) {
  57.         final TransformCSFunc<A, B, S> self = this;
  58.         final Monoid<M> m_ = m;
  59.         return new F4<F<B, M>, A, F2<M, S, M>, S, M>() {
  60.  
  61.             @Override
  62.             public M f(F<B, M> a, A b, F2<M, S, M> c, S d) {
  63.                 return self.f(m_, a, b, c, d);
  64.             }
  65.         };
  66.     }
  67.  
  68.     <M> F5<Monoid<M>, F<B, M>, A, F2<M, S, M>, S, M> f() {
  69.         final TransformCSFunc<A, B, S> self = this;
  70.         return new F5<Monoid<M>, F<B, M>, A, F2<M, S, M>, S, M>() {
  71.  
  72.             @Override
  73.             public M f(Monoid<M> a, F<B, M> b, A c, F2<M, S, M> d, S e) {
  74.                 return self.f(a, b, c, d, e);
  75.             }
  76.         };
  77.     }
  78. }