[Haskell-cafe] Bool is not...safe?!

Stefan Monnier monnier at iro.umontreal.ca
Thu Jul 5 14:27:15 UTC 2018

> There is an opinion that Bool type has problems. It's "dangerous", because
> it's not good to be used as flag for success/fail result. I read this post:
> https://existentialtype.wordpress.com/2011/03/15/boolean-blindness/ and was
> shocked. How popular is such opinion? Is it true, that bool is "bad" type?

To me the argument boils down to the `head` case mentioned by Alex.

Most programming languages force you to write code like

    if List.empty l then
        ... x = List.head l ...

where the problem is that the fact that the List.head call will find the
list non-empty is not obvious (in the sense that it requires reasoning).

In contrast

    case l
    | nil => ...
    | cons x xs => ...

makes it trivially obvious that `x` is extracted from a non-empty list
without any reasoning needed at all.


More information about the Haskell-Cafe mailing list