Shapeless and Scalding

45 views
Skip to first unread message

Matt Martin

unread,
Mar 27, 2015, 4:56:26 AM3/27/15
to shapel...@googlegroups.com
I'm very new to Shapeless, but I thought I'd dive in and see if I could make basic use of HList's within Scalding to get around the Tuple22 limit.  As far as I can tell, half the battle is providing two implicits:
  1. a TupleConverter converts from a TupleEntry to an HList 
  2. a TupleSetter converts from an HList to a Tuple
I think I've got #1 working (or at least in some basic capacity), but I'm having trouble trying to convert from an HList to a Tuple (note this Tuple bears no relation to Scala's tuples; it is a Cascading construct).  I put together a (very basic) Gist of what I've got so far and was hoping some kind soul could point me in the right direction:


Thanks in advance!
Matt 

Miles Sabin

unread,
Mar 27, 2015, 6:35:29 AM3/27/15
to shapel...@googlegroups.com
First off, most shapeless discussion now happens on Gitter
(https://gitter.im/milessabin/shapeless) and this mailing list is now
deprecated in favour of the Typelevel mailing list,

https://groups.google.com/group/typelevel

I think what you're doing looks more or less along the right lines.
Because you want a List[Any] to feed into the Tuple constructor you
don't actually need any structure in the HList argument, so something
like this ought to do the trick,

implicit def hListSetter[L <: HList, N <: Nat]
(implicit tl: ToList[L, Any], len: Length.Aux[L, N], ti: ToInt[N]):
TupleSetter[L] =
new TupleSetter[L] {

override def apply(arg: L): Tuple = {
val argList: List[Any] = arg.toList
new Tuple(argList:_*)
}

override def arity: Int = ti()
}

Cheers,


Miles

--
Miles Sabin
tel: +44 7813 944 528
skype: milessabin
gtalk: mi...@milessabin.com
g+: http://www.milessabin.com
http://twitter.com/milessabin

Matt Martin

unread,
Mar 28, 2015, 5:40:54 PM3/28/15
to shapel...@googlegroups.com
Thanks so much!
Reply all
Reply to author
Forward
0 new messages