The illegal state not represented is a huge aspect that people need to appreciate. I see a lot of "stringly typed" programming. It seems to be very common in Python and with beginner programmers. For example as map keys or Python dict keys). With ADTs a huge class of runtime errors are not possible.
I love the explanation, I understood Product and Sum for the first time so thank you for that. My brain is wired towards extensibility so I even though I understand the purpose of ADTs for types that are universally finite (True and False / Up, Down, Left and Right), it's hard for me to understand why you would not use an extensible pattern for the weather type. Weather can be LOTS of things that can cause a whole array of feelings: Tornado, Sandstorm, Blizzard, Foggy etc. and maybe you just want to provide the functionality for these structures/objects, but let client code provide their types. Let's say we have an application like the one you provided for weather requests/responses, but we want to make it open to extension, closed to change (open for external addons/plugins), how would you implement this system to let client code provide their own VolcanicThunderStorm (silly example I know) weather type with it's own feeling? I feel like Scala is about the best of both worlds of FP + OOP and I want to understand the pros and cons of both. Thanks in advance.
Legit point. The weather example was really simplified to prove a point (which no doubt you understood). As your logic gets increasingly complicated, you will probably want to expand on your ADTs, e.g. instead of a Sum type you might want to use a Product type to support many more possible values.
great Videos! thanks a lot. an observation. the function naiveFeeling() shouldn't be receiving the NaiveWeather type alias as the argument type, instead of String? greetings
Hi, great videos. I have learnt from them a lot. I have a suggestion about what you could do for the next video. What is the difference between _ and * in type parameter. Here is a post from stackoverflow stackoverflow.com/questions/61686150/difference-between-star-and-underscore-in-type-parameter but it is hard to understand for newcomers. If you could explain it, but in a more simplified way.