Introduction to Variance in Scala with Wiem Zine Elabidine - Scala with Friends #1

preview_player
Показать описание
Here's the first episode in a series of collaborations with excellent developers and speakers from the Scala community.
My first guest is Wiem Zine Elabidine - a backend Scala developer, open source contributor and fellow conference speaker.

In this video, she tells me and you what variance is, what we can do with it, and how the ZIO library uses variance to power type inference in its most common operations.

You can follow Wiem on social media:

If you liked the video, please like and subscribe!

Table of contents:

0:00 - Introduction, welcoming Wiem

0:40 - Subtyping
3:10 - Nothing, Any
4:28 - Case study: common type for generic parameter
5:57 - Upper type bounds
6:39 - Lower type bounds
8:20 - Variance basics
10:28 - Variance as a means to preserve subtyping
11:36 - Making Box contravariant
12:17 - Dual variance of Function1
14:10 - Inverting the variance with type bounds
18:10 - Inverting the variance of a contravariant type
18:48 - How variance composes
20:13 - Variance in ZIO
23:49 - Type bounds in ZIO methods
25:47 - How variance helps us avoid mistakes in design
26:21 - Summary, parting words

Useful links:

Scala documentation:

Other posts:

Рекомендации по теме
Комментарии
Автор

Good Explanations, helps a lot for people who are confused about variance :)

ShankarShastri
Автор

Your videos are pure gold!, thanks for sharing.

jesusignaciocastillobarrio
Автор

Jakub good variance explanation, Please continue with these kinds of pair programming videos.
Looks awesome.
Cheers!

ernestochero
Автор

Great explanation. Thank you for making that vid!

marcinjoz
Автор

Hello, thank you for your video that helped me to understand the concept of variance ! At 12:18, I'm having hard time to understand exactly why does function has a contravariant parameter and a covariant output. By the way, It seems logical to me that eat(Chili) works but when I think with a "contravariant" way, it is not since Chili is a subclass of Ingredient, and contravariant means we want superclass of ingredient. Could you re-explain me that please ? Thanks !

y.
Автор

Great video. If I understand correctly the function with the signature ::(a:A): List1[A] is invariant in A, but adding the bounds ::[A1>:A](a:A1): List1[A1] makes it covariant in A.

nayak
Автор

Great video, I think I finally understood what contravariance on the input parameter of a function means.
What tool are you using for pairing in Intellij? Looks very similar(performance wise) to VSCode live share!

bernardo
Автор

Can you discuss about the functors and Monads?

greenhorn
Автор

Jakub, you know too much for a learner ) You would better pretend not knowing that stuff and asking simple questions ) anyway thank you 👍

shef