Comment by arjvik
17 hours ago
What about the (incredibly unlikely, i'll admit) scenario where somebody attempts to pass the literal 'Expected a Collection' as an instance of this type? What's the best way to insert a warning, but also guarantee the type is unsatisfiable?
('Expected a Collection' & never)?
It’s very situational. If you can predict the shape of error cases, anything that doesn’t match that shape will do. If you can’t, you can fabricate a nominal type in one way or another (such as the symbol suggestion made by a sibling commenter, or by a class with a private member). The broad strokes solution though is to use a type that:
1. Won’t be assignable to the invalid thing.
2. Conveys some human-meaningful information about what was expected/wrong and what would resolve it.
Perhaps you could make it a private Symbol? Then it should be impossible semantically to use it from the outside.
Thanks for the tip ill try it out