[Haskell-cafe] Ensuring that blank-state has been handled in UIs?

Tomas Carnecky tomas.carnecky at gmail.com
Sun Apr 16 12:03:26 UTC 2017


Make your 'displayTable' function take a 'NonEmpty a' instead of a List
(eg. [a] or Vector a). That at least ensures that you won't ever be showing
an empty table. I don't think there is a Map/Set-equivalent of NonEmpty.
But you will have to convert a Map/Set into a list at some point, and
that's where you can again use NonEmpty.

https://downloads.haskell.org/~ghc/8.0.1/docs/html/libraries/base-4.9.0.0/Data-List-NonEmpty.html

On Sun, Apr 16, 2017 at 1:54 PM Saurabh Nanda <saurabhnanda at gmail.com>
wrote:

> 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.
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170416/e23af1c9/attachment.html>


More information about the Haskell-Cafe mailing list