def opt[H <: HList, N <: Nat, F, R](t: T, f: F)( implicit hlister: FnHListerAux[F, H => R], length: LengthAux[H, N], toHList: FromTraversable[H], size: ToInt[N]): Option[R] = for { ts <- if (size() > 0) tailfind(t) else rawdata.find { _ == t }.map { _ => Nil } hl <- toHList(ts.take(size())) op <- nonFatalCatch.opt { hlister(f)(hl) } } yield op
where the T is the input type (in practice always String) and R is the output type. The various implicits witness that we can get the arguments of our function as an HList, that we can work out the length of that HList, that we can turn our rawdata (a field in this case) into an HList, and that we can turn our size into an Int value so we can take that many elements from ou rawdata.
It takes a little while to puzzle though, but it works really well and is nice and compact.
cheers,
jed.
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I just realized that a tuple approach isn't going to better than Mark's boilerplate plugin. In particular I hoped to circumvent the 22-arg limitation, but tuples are likewise limited. While I have figured out the example I put forth in this post, the use case in my project is a little more involved. I'll let y'all know how it goes.
This has been great, tho. I'm finding out there is a whole world in the Scala type system that I am ignorant of.