Refined typeclasses using generics