In Scala, is there a shorthand for reducing a generic type's arity?

前端 未结 3 894
灰色年华
灰色年华 2021-01-31 22:29

I want to call Scalaz\'s pure method to put a value into the State monad. The following works:

type IntState[A] = State[Int, A]
val a = \"a\".pure[I         


        
3条回答
  •  太阳男子
    2021-01-31 23:15

    the most popular way of reducing arity is kind-projector (https://github.com/non/kind-projector) plugin that is also used in cats library. By enabling this plugin your example can be transformed to:

    val a = "a".pure[State[Int, ?]]
    

    Note: this syntax will be enabled in Dotty by default.

提交回复
热议问题