I have created a simple trait
and service:
@finalAlg
@autoFunctorK(true)
trait BettingService[F[_]] {
def put(bet: Bet): F[Bet]
}
class BettingServiceMock[F[_] : Async] extends BettingService[F] {
override def put(bet: Bet): F[Bet] = {
val id = randomUUID().toString
for {
created <- Bet(BetId(id), bet.stake, bet.name)
} yield created
}
}
Bet
and BetId
are case classes
:
case class Bet(betId: BetId, stake: BigDecimal, name: String)
case class BetId(betId: String) extends AnyVal
When I ran this program, I got an error: Error:(12, 21) value map is not a member of model.Bet <- Bet(BetId(id), bet.stake, bet.name)
It is something strange for me - why I cannot return good type from for-comprehension
? The idea of this is to return same object as given as parameter, but with random id.
I thought that maybe I need instance of new Bet
class, but then I could not return it as F[_]
as I think.
Bet(BetId(id), bet.stake, bet.name)
is of typeBet
but expected type isF[Bet]
.Try
or
or
or