Meta:
I don't know whether to laugh or cry.
Algebraic has several problems, but your code has other problems.
I suggest to take a look at Nullable, especially the version that
makes a constant value the "null".
Also try to almost never use cast() in your code, unless you
_really_ know what you are doing.
Expecting a bit of magic from the D compiler is OK. But someone
has to ask for it in a clean way, someone has to implement it,
and someone else has to accept it.
Ask if you need more help.
Bye,
bearophile