I edited my comment within a couple minutes of posting it. Sorry about the confusion.
-11 karma · joined June 2, 2017
I edited my comment within a couple minutes of posting it. Sorry about the confusion.
I personally stay home as much as I can, but I have certain privileges many others don't.
This pandemic has been hard on all of us. Take care.
Injectables seemed scary right until the moment when I started taking them, after which they became a normal part of my life.
https://www.poz.com/drug/cabenuva seems to suggest it is intramuscular (administered in the buttocks, which is not hard to do by oneself) but requires a healthcare provider. Not sure why, there might be storage requirements and such.
But you can encode fulfilment into a smart contract for physical goods, assuming that those physical goods have some digital representation on-chain. Discrepancies between the chain and the real world continue to be resolved through the court systems in various jurisdictions, but on-chain activity is just strong evidence that any court can rely on.
> a distributed ledger only has value over and above a non-distributed one if other parties worry about the centralised database manager tampering with records
An alternative viewpoint is that a centralized database manager can be seen as a potential risk. One of the general ways we progress in society is when we reduce sources of risk, and a permissioned blockchain where you need 2/3rds of a cabal to collude is a pretty clear reduction of risk compared to a centralized DB. (I mean, how would you keep track of whether a central DB has been tampered with? You'd probably maintain your own copy, reconcile the two periodically, and flag discrepancies if and when they happen. That's exactly what a blockchain is.)
To be clear, I'm pretty skeptical about blockchains in general, but this seems like a very compelling use case.
A blockchain (not proof-of-work, but permissioned/BFT-based) is pretty clearly the optimal way to have an irrevocable digital trail.
Take the levels of scrutiny applied to laws and regulations in equal protection lawsuits, for example. Why is judicial review for racial discrimination covered under strict scrutiny, but sex discrimination only covered under intermediate scrutiny? There's no statute prescribing this—American courts invented it.
So, I think you're right about a result type being isomorphic to checked exceptions, for the reasons you laid out. If you compare it to Rust, what ends up happening is similar -- many libraries return an error type that's a union of all their dependencies' error types, and binaries end up using an "everything" anyhow::Error type in the end. However, I think where sum types in general end up working and checked exceptions don't are:
1. Sum types don't encourage a mix of checked and unchecked exceptions the way Java does. Translating from Rust, all exceptions that are meant to be handled by regular users are checked. The only exceptions that are unchecked are broken invariants (panics), which usually end up being handled either through aborting the program or through some sort of top-level restart logic. You could write Java in that style but it's not the ecosystem's convention.
2. Sum types are more general than checked exceptions: they can be used to express nulls and business logic as well. I suspect checked exceptions would have worked better if Java also had nullable and non-nullable types, because nullability is such a common source of errors.
3. You're right that you can drop an error on the floor with sum types as well, just like an empty catch block with exceptions. But that just doesn't happen nearly as often in practice, because result types form a closed set. With checked exceptions, in practice you often end up with a method throwing both checked and unchecked exceptions, and the same syntax is used to handle both. I think checked and unchecked exceptions are fundamentally very, very different and mixing the two is a mistake.
Once again, thank you for your response.
Product types model "x and y", sum types model "x or y". One of them is universal. The other has been totally missing from mainstream languages until recently. No wonder our software sucks so much.
Sum types are a zillion times more important.
Our field has a terrible reputation for quality. In my estimation roughly 70-80% of that is directly or indirectly because of the lack of sum types.
Directly: people don't have the right tools to make invalid states in their business logic unrepresentable.
Indirectly: the lack of sum types results in broken null and error handling.
Every language has product types. Every programmer understands how useful product types are. Why in the world would the same not apply to sum types?