iniyanp
2/24/2017 - 8:10 PM

UserMonadQuery

UserMonadQuery

How to get Process[Task, A] from user monad operations.

sealed trait DbOp[A] extends Product with Serializable

object DbOp {

  final case class Select[A, T <: Table](
      table: T,
      column: T#Field[A],
      condition: Clause)
      extends DbOp[Process[Task, A]]
      
If we have this, we can't do subsequent DB operations for the elements inside a stream.

Ex:
 for {
          rs <- D.select(
            schema.Topic,
            schema.Topic.state,
            schema.Topic.name === selector.resolution)
            
          //rs => Process[Task, A]
          //But this `for sequence is for DBCastOp.` we cant do the below 
          //operation for Process :( 
          
          //It will report this issue.
          
          // found   : scalaz.concurrent.Task[Nothing]
          //[error]  required: tortuga.Free[orion.dbcastop.DBCastOp,?]
          
          optState <- rs.runLast 
          
          //What we can do is rs.runLast.run . but that's not what we want.

          pair = optState match { ... }
 }


what is the right solution?

1. Instead of our DB retruns DbOp[Process[Task, A]] we return DB[Vector[A]]? but we don't want to
hold up memory for this?
2. we don't want to deal with ALl complex operations done in orion.