|
|
|
|
|
by leif
5435 days ago
|
|
That's not the point, the point is that Maybe is the right way to handle what nil (or None or null) fails to handle properly. Scala gets it right too, IIRC, with Nullable. 1. A "null" instance of one type should not be conflated with a "null" instance of a separate type.
2. By type-wrapping in a Maybe, you declare where you need to be able to handle nulls and where you are free to ignore them (but can never pass them in). You confine the null to specific regions of your code.
3. You force your code's clients to think about the null case wherever you make it visible. |
|