<div dir="ltr"><div dir="ltr">length is part of the Foldable class:</div><div dir="ltr"><br></div><div>length = <span class="gmail-annot" style="color:rgb(0,0,0)"><a href="https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.Foldable.html#foldl%27" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">foldl'</span></a></span><span style="color:rgb(0,0,0)"> </span><span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="gmail-hs-glyph" style="color:rgb(220,50,47)">\</span><span id="gmail-local-6989586621679508859" style="color:rgb(0,0,0)"><span class="gmail-annot" style=""><a href="https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.Foldable.html#local-6989586621679508859" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">c</span></a></span></span><span style="color:rgb(0,0,0)"> </span><span class="gmail-annot" style="color:rgb(0,0,0)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">_</span></span><span style="color:rgb(0,0,0)"> </span><span class="gmail-hs-glyph" style="color:rgb(220,50,47)">-></span><span style="color:rgb(0,0,0)"> </span><span class="gmail-annot" style="color:rgb(0,0,0)"><a href="https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.Foldable.html#local-6989586621679508859" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">c</span></a></span><span class="gmail-annot" style="color:rgb(0,0,0)"><a href="https://hackage.haskell.org/package/base-4.14.0.0/docs/src/GHC.Num.html#%2B" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">+</span></a></span><span class="gmail-annot" style="color:rgb(0,0,0)"><span class="gmail-hs-number" style="color:rgb(38,139,210)">1</span></span><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span><span style="color:rgb(0,0,0)"> </span><span class="gmail-annot" style="color:rgb(0,0,0)"><span class="gmail-hs-number" style="color:rgb(38,139,210)">0</span></span></div><div dir="ltr">It is probably defined this way s.t. it satisfies:<div>length = length . toList</div><div>Not the actual definition, but you can read toList as:</div><div>toList = foldr (:) []</div><div><br></div><div>So as soon as one defines foldr for pairs:<br><pre style="color:rgb(0,0,0)"><span id="gmail-local-6989586621679508647"><span id="gmail-local-6989586621679508613"><span class="gmail-annot" style=""><a href="https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.Foldable.html#local-6989586621679508613" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var gmail-hs-var gmail-hs-var gmail-hs-var" style="color:rgb(7,54,66)">foldr</span></a></span></span> <span id="gmail-local-6989586621679508612"><span class="gmail-annot" style=""><a href="https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.Foldable.html#local-6989586621679508612" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">f</span></a></span></span> <span id="gmail-local-6989586621679508611"><span class="gmail-annot" style=""><a href="https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.Foldable.html#local-6989586621679508611" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">z</span></a></span></span> <span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="gmail-annot" style=""><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">_</span></span><span class="gmail-hs-special" style="color:rgb(220,50,47)">,</span> <span id="gmail-local-6989586621679508610"><span class="gmail-annot" style=""><a href="https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.Foldable.html#local-6989586621679508610" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">y</span></a></span></span><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)">=</span> <span class="gmail-annot" style=""><a href="https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.Foldable.html#local-6989586621679508612" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">f</span></a></span> <span class="gmail-annot" style=""><a href="https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.Foldable.html#local-6989586621679508610" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">y</span></a></span> <span class="gmail-annot" style=""><a href="https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.Foldable.html#local-6989586621679508611" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">z</span></a></span></span></pre></div><div>We get:</div><div>toList (a,b) = [b]</div><div><br></div><div>Using the 'natural' property: length = length . toList</div><div>We obtain: length (a,b) = length [b] = 1</div></div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 23, 2020 at 10:22 AM Manuel Schneckenreither <<a href="mailto:manuel.schnecki@gmail.com">manuel.schnecki@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">    >>>>> "HT" == Henning Thielemann <<a href="mailto:lemming@henning-thielemann.de" target="_blank">lemming@henning-thielemann.de</a>> writes:<br>
<br>
    HT> "length (a,b) == 1" is only a consequence of defining instance<br>
    HT> Foldable for pairs. It was not the argument to implement that<br>
    HT> instance, at all.<br>
<br>
What was the argument to use 1, not 2 for instance? <br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div></div>