Shapeless: generic lens parameterized by case class or field
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Based on: import shapeless . _ case class Content ( field : Int ) lens [ Content ] >> 'field I am trying to make a lens-creating method, something along: def makeLens [ T <: Product ]( s : Symbol ) = lens [ T ] >> s But it seems non-obvious. Is it possible to do? If not, the end result I'm trying to achieve is a generic method for updating nested Maps with case-class contents, e.g.: import scalaz . _ import Scalaz . _ import PLens . _ import shapeless . _ import shapeless . contrib . scalaz . _ def nestedMapLens [ R , T <: Product