Implicit arguments: how to encode in function signature?

后端 未结 1 1152
隐瞒了意图╮
隐瞒了意图╮ 2021-01-25 12:13

Following the awesomely enlightening question by @TravisBrown concerning the enumeration of ADTs using shapeless, I am left with the following code snippet:

impl         


        
1条回答
  •  情歌与酒
    2021-01-25 12:52

    If you look at the definition of implicitly[X], you can see that is requires an implicit argument of type X in scope. In your example, you have implicit ev: T in scope, which is not enough to call implicitly[EnumerableAdt[T]]! Try the following definition instead:

    def imply[T](implicit ev: EnumerableAdt[T]):Set[T] = ev.values
    

    0 讨论(0)
提交回复
热议问题