I\'ve often wondered why languages with a null
representing \"no value\" don\'t differentiate between the passive \"I don\'t know what the value is\">
In haskell you can define something like this:
data MaybeEither a b = Object a
| Unknown b
| Null
deriving Eq
main = let x = Object 5 in
if x == (Unknown [2]) then putStrLn ":-("
else putStrLn ":-)"
The idea being that Unknown values hold some data of type b
that can transform them into known values (how you'd do that depends on the concrete types a
and b
).
The observant reader will note that I'm just combining Maybe and Either into one data type :)