Open ggalmazor opened 8 years ago
@ggalmazor For the last point - it depends on how the values inside foldable are composed. According to the explanation in exercise:
fold, also called combineAll, combines every value in the foldable using the given Monoid instance
foldK is similar to fold but combines every value in the foldable using the given MonoidK[G] instance instead of Monoid[G]
And for Option
instance combineK
is defined as follows:
def combineK[A](x: Option[A], y: Option[A]): Option[A] = x orElse y
where orElse
is:
@inline final def orElse[B >: A](alternative: => Option[B]): Option[B] =
if (isEmpty) alternative else this
So when it goes about combining a bunch of Option
s, the 1st non-empty values would be taken
Thanks for the explanation, @tr4rex!
Although it's been some time since I did the exercises, I can see what you say :)
Thanks!
I'm opening this issue just to give some feedback on these two exercises.
OptionT
is introduced. You can deduce some of its meaning from the text on the exercise but I've had to expand it with this article. Seems right but can't know it it the same thing. Also, in the article there are some nice examples to understand in what cases you'd useOptionT
.MonoidK
is referred out from nowhere before having explained it. Also had to go to the sources to expand on this.It would be nice to explain why
OptionT[F, A]
&MonoidK[F, A]
instead ofOptionK[F, A]
&MonoidK[F, A]
orOptionT[F, A]
&MonoidT[F, A]
. Don't both suffixes mean the same thing?