ProjectSeptemberInc / freek

Freek, a freaky simple Free to combine your DSL seamlessly
Other
198 stars 19 forks source link

implicitNotFound of Lifter2 #24

Open bayarmunkh opened 7 years ago

bayarmunkh commented 7 years ago

Example:

object TestService {
  sealed trait Account

  sealed trait RepoF[A]

  sealed trait Repo[A]
  case class Query(no: String) extends Repo[Either[String, Account]]
  case class Store(account: Account) extends Repo[Either[String, Account]]
  case class Delete(no: String) extends Repo[Either[String, Unit]]

  object Repo {
    type PRG = Repo :|: NilDSL
    val PRG = freek.DSL.Make[PRG]
    type O = Either[String, ?] :&: Bulb
  }

  def query(no: String) = Query(no)
  def store(account: Account) = Store(account)
  def delete(no: String) = Delete(no)

  // How do I write this function here ?
  def update(no: String): OnionT[Free, Repo.PRG.Cop, Repo.O, Int] = for {
    a <-  Query(no).freeko[Repo.PRG, Repo.O]
    _ <-  Store(a).freeko[Repo.PRG, Repo.O]
  } yield 1
}

when import cats.instances.either._ isn't imported, it gives a bit confusing compile error.

could not find implicit value for parameter lifter2:
freek.Lifter2.Aux[Either[String,TestService.Account],TestService.Repo.O,TestService.Account]

basically it doesn't tell an implicit Application[G[_]] is missing in the scope. Any way to escalate implicitNotFound of Lifter2 into this scope?

mandubian commented 7 years ago

Could you try to add one to check what it does? I think we can improve the message but the precision of it will be relative naturally.