Skip to content

Instantly share code, notes, and snippets.

@aeyakovenko
Last active July 11, 2016 21:22
Show Gist options
  • Save aeyakovenko/a76ef1c7b8b18e26fc567f3a8572f995 to your computer and use it in GitHub Desktop.
Save aeyakovenko/a76ef1c7b8b18e26fc567f3a8572f995 to your computer and use it in GitHub Desktop.

So I can explicitly define everything via:

  type SchedulerState[X] = StateT[Trampoline, D.SchedulerState, X]
  type SchedulerM[A] = XorT[SchedulerState, String, A]
def bailScheduler[A](msg: String): SchedulerM[A] =
    XorT.left[SchedulerState, String, A](StateT.pure(msg))

But if i try to generalize this i get errors

  type XorTStateT[F[_], S, A] = XorT[({type l[X] = StateT[F, S, X]})#l, String, A]
def bail[F[_], S, A](msg: String): XorTStateT[F, S, A] =
    XorT.left[({type l[X] = StateT[F, S, X]})#l, String, A](StateT.pure[F, S, String](msg))


[info] Compiling 2 Scala sources to /Users/anatolyy/mesos-edsl/target/scala-2.11/classes...
[error] /Users/anatolyy/mesos-edsl/src/main/scala/control.scala:20: could not find implicit value for parameter F: cats.Applicative[F]
[error]     XorT.left[({type l[X] = StateT[F, S, X]})#l, String, A](StateT.pure[F, S, String](msg))
[error]                                                                                      ^
[error] /Users/anatolyy/mesos-edsl/src/main/scala/control.scala:20: could not find implicit value for parameter F: cats.Functor[[X]cats.data.StateT[F,S,X]]
[error]     XorT.left[({type l[X] = StateT[F, S, X]})#l, String, A](StateT.pure[F, S, String](msg))
[error]                                                            ^
[error] two errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 1 s, completed Jul 11, 2016 1:32:55 PM

works!!!

  type XorTStateT[F[_], S, A] = XorT[({type l[X] = StateT[F, S, X]})#l, String, A]
	def bail[F[_], S, A](msg: String)(implicit I1: Applicative[F], I2: Functor[({type l[X] = StateT[F, S, X]})#l]): XorTStateT[F, S, A] =
    XorT.left[({type l[X] = StateT[F, S, X]})#l, String, A](StateT.pure[F, S, String](msg))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment