<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 30, 2015 at 4:33 AM, Lana Black <span dir="ltr"><<a href="mailto:lanablack@amok.cc" target="_blank">lanablack@amok.cc</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":of" class="a3s" style="overflow:hidden">
Is there any particular reason why the 'all' function returns True when<br>
supplied with an empty list (or any other foldable)? I'm aware that it<br>
is implemented via All monoid instance, my question is whether this<br>
behaviour is intentional or it can be considered a bug.</div></blockquote></div><br></div><div class="gmail_extra">Hi Lana, this is a good question, variants of which are actually asked quite often.<br><br></div><div class="gmail_extra">The function 'all' has type signature (a -> Bool) -> [a] -> Bool.<br><br>Given a list of as that's split arbitrarily into bs and cs such that as == bs ++ cs,<br>'all' has the property that: all p as == all p bs && all p cs, for any boolean predicate p.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">So if bs or cs is the empty list, the property forces all f [] == True.<br><br></div>For a similar Q&A on related functions, see<br><br><a href="https://groups.google.com/forum/#!msg/elm-discuss/sPS98RnV0Og/dSddTp8VXYcJ">https://groups.google.com/forum/#!msg/elm-discuss/sPS98RnV0Og/dSddTp8VXYcJ</a><br><div><div><br clear="all"><div><div class="gmail_extra"><div><div class="gmail_signature">-- Kim-Ee</div></div>
</div></div></div></div></div>