3 ms·
I hate to say "you should," but you really should spend a few hours going through a Haskell tutorial. You'll be surprised how different things are. The Haskell
by fusiongyro 14y ago
I hate to say "you should," but you really should spend a few hours going through a Haskell tutorial. You'll be surprised how different things are.
The Haskell equivalent to this Scala Option fiasco is Maybe, which is defined as:
data Maybe a = Just a | Nothing
"Nothing" is not a null reference and "Just a" is not an object with a pointer to another object. "Just a" is a constructor with a single value parameter. "Nothing" is a constructor that takes no parameters. These are values, not references or values with references or references to references. "Nothing" always has a specific type (Maybe Integer, Maybe String, etc.) even though it has no auxiliary data of its own. This means "Nothing" can't show up anywhere you have values--it can only show up where you expect a value of type Maybe. Indeed, the whole point here is that you are forced to explicitly reckon with the possibility of null where it can happen, and you are freed from responsibility to worry about it everywhere else.
Haskell does just fine without the kind of null we're talking about, in a way that I suspect is fundamentally different from what you're intuiting.