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
Not sure if this qualifies as better, but here is one approach that @kmizu tweeted the other day:
scala> trait TF {
| type Apply[A]
| }
defined trait TF
scala> type Curried2[F[_, _]] = TF {
| type Apply[X] = TF {
| type Apply[Y] = F[X, Y]
| }
| }
defined type alias Curried2
scala> "a".pure[Curried2[State]#Apply[Int]#Apply]
res7: scalaz.State[Int,java.lang.String] = scalaz.States$$anon$1@1dc1d18
You can make it look a little nicer by using symbolic type aliases.
scala> type ![F[_, _]] = TF {
| type ![X] = TF {
| type ![Y] = F[X, Y]
| }
| }
defined type alias $bang
scala> "a".pure[![State]# ![Int]# !]
res9: scalaz.State[Int,java.lang.String] = scalaz.States$$anon$1@1740235