UX/UI Engineer & Full Stack Developer
It seems obvious in hindsight, but honestly a lot of this didn’t click for me until I realized that Never will likely be used in conjunction with parameterized types like Task or Html.
Note that the docs for Never assert that “generally speaking, you do not want Never in your return types” so take this example with a grain of salt.
This function compiles just fine. The really neat part is if I change Nothing to Just "any type here" then I get a compiler error because Never doesn’t have any values. It forces this function to actually always return Nothing by leveraging the type system!
Just "any type here"