scalawithcats / scala-with-cats

Source code for Scala with Cats
http://underscore.io/books/scala-with-cats
390 stars 129 forks source link

5.4 Exercise: Monads: Transform and Roll Out is misleading #247

Open asarkar opened 5 months ago

asarkar commented 5 months ago

The problem description states:

Responses are therefore represented as a stack of monads:

type Response[A] = Future[Either[String, A]]

and methods getPowerLevel and canSpecialMove both return Response.

However, the solution redefines the Response[A] type:

type Response[A] = EitherT[Future, String, A]

This is very misleading. Using the Response shown in the problem description, there's no monad stack involved, and it is difficult to understand what the exercise wants.

IMO, it'll be clearer if the Response type definition is left as an exercise for students, with the requirement that the stack is of type Future[Either[String, *]].