Hi Everyone,
In most user-interfaces we need special-treatment for blank states (zero-item state). For example:
* In case there are no customers, don't show an empty table, instead show the message "You seem to have no customers, why not start by creating one..."
* In case there are no bookings, don't show an empty table, instead show the message, "No bookings here. Want to create one?"
* In case there are no search results, don't show an empty table, instead show the message, "No items found. Undo your last filter?"
In some cases, the one-item case also needs special treatment, but I'm unable to come with relatable examples at the moment.
A lot of times the dev simply forgets about the blank state, and it is caught during QA, which results in a quick-fix on the following lines:
if length item > 0 then displayTable else showBlankState
if Data.Map.Strict.size map > 0 then displayTable else showBlankState
if Data.Set.Ordered.size set > 0 then displayTable else showBlankState
Is there a way to prevent this bug from the get-go? Can we use the type-system (or anything else) to enforce the dev to at least _think_ about the blank state? Obviously, the type system can't help us with _what_ needs to be done with the blank state, but at least it can _remind_ the dev at compile-time about handling blank states.
-- Saurabh.
_______________________________________________