3 ms·
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'
by arjvik 1y 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)?
- deleted 1y ago[deleted]
- bubblyworld 1y agoPerhaps you could make it a private Symbol? Then it should be impossible semantically to use it from the outside.
- cdaringe 1y agoThanks for the tip ill try it out
- eyelidlessness 1y agoIt’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.