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

前端 未结 3 893
灰色年华
灰色年华 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 22:54

    For concise partial type application (arity-2) in Scala, you can infix type notation as followings.

    type ![F[_, _], X] = TF { type ![Y] = F[X,  Y] }
    
    "a".pure[(State!Int)# !]
    

    Note that we can infix notation for two arity type constructor (or type alias).

提交回复
热议问题