(re)constructing sequences with Alternative - Scala tutorial

preview_player
Показать описание
Another week, another functional pattern Cats helps us with - splitting and constructing sequences with the Alternative typeclass.

If you enjoyed this video, please like and subscribe, and hit the bell icon so you don't miss another one ;)

Table of contents:

0:00 - Introduction, problem statement
0:50 - `partition`-based approach
1:52 - `foldLeft`-based approach
3:28 - `separate`
5:04 - `separate` with tuples
6:26 - Using Alternative
8:37 - Quick close look at Alternative
9:24 - Motivation for Alternative
10:45 - Parting words

If you want to learn more:

#scala #cats #typeclasses #functional-programming
Рекомендации по теме
Комментарии
Автор

Thanks for the video!
I just want to add that it is possible to split a sequence of *Eithers* without *cats.Alternative*
or folding over a sequence using *partitionMap* method:

val lst: List[Either[String, Int]] = ???
val (lefts, rights): (List[String], List[Int]) = lst.partitionMap(identity)

v_pdil