News for hackers. Stuff that matters.
Re:Sshole by eru on Friday November 06, 2026 @04:33AM (#50390180)
I'm not sure how well the 'forcing' works for Rust and C++. You can definitely do this kind of thing in dependently typed languages.
Re:Sshole by cowlevel on Friday November 06, 2026 @08:05AM (#50391862)
The type is akin to optional<int>. You can't add 5 to it, you have to dereference it first which crashes if it was null (0 or another chosen value).
Re:Sshole by eru on Friday November 06, 2026 @09:36PM (#50401092)
Well, in Rust you would use pattern matching, which can't even crash.

In Haskell, the closest thing to adding 5 to an optional value would be something like:

    fmap (5+) my_optional_value
This one leaves 'Nothing' alone, but adds 5 in case the value is present.