I mistakenly applied length to a (pa,ir) and took a little while to find out, because the code would compile!
So I looked up :t length, which told me that its argument is only required to be a Foldable.
That's how I found that there's a Foldable instance for (,):
instance Foldable ((,) a) where
foldMap f (_, y) = f y
foldr f z (_, y) = f y z
length _ = 1
null _ = False
which incidentally overrides what would be the automatic definition of length.
What is a Foldable instance for (,) useful for? Especially considering that some of what derives from a minimal definition (null and length) of it has been overridden anyway.
One way through which something nontrivial can be done with
Foldable ((,) a)is bringing in theFoldableinstance forCompose:Also,
Foldablehappens to be a superclass ofTraversable, which in turn grants ussequenceA:The perspective these instances suggest is that of
(a, b)values seen asbvalues annotated with anatag.sequenceA, then, shifts the tag to the values in the other functorial structure (in the example above, a list).