I'm working with scala and scalaStorm for a project, i'm currently using velvia's scalastorm library from github (https://github.com/velvia/ScalaStorm), and i'm trying to enrich it. I want to add type safety to storm tuple's that are by default all java Object. In storm there are entities called bolts that take tuple as input and output other tuples. I want to do something like this:
class StormBolt[T*][K*]{
}
So I can write directly:
class MyBolt[Int, Date, String][Int, String]{
}
I didn't find anything that let's me do this in some way. I appreciate any tip in implementing such feature! Adding type safety to the library wouldn't be a shame! Thank you
You can do it with simple generic types or use HList from shapeless(https://github.com/milessabin/shapeless/wiki/Feature-overview:-shapeless-2.0.0#heterogenous-lists)
trait StormBolt[T, K] {
}
trait MyBolt extends StormBolt[(Int, Date, String), (Int, String)]
or with shapeless
trait StormBolt[T <: HList, K <: HList] {
}
trait MyBolt extends StormBolt[Int :: Date :: String :: HNil, Int :: String :: HNil] {
}
with shapeless you can get lot's of cool features, you can take a look at feature overview, maybe you'll find some of them useful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With