[Haskell-cafe] Textbook example of instance Foldable ((,) a)

Tom Ellis tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Mon Nov 23 21:22:32 UTC 2020


On Mon, Nov 23, 2020 at 09:54:26PM +0100, Francesco Ariis wrote:
> Il 23 novembre 2020 alle 14:40 Zemyla ha scritto:
> > So what should maximum (2, "potato") be?
> 
> For people who did not agree with `instance Foldable (,) a`, a
> type error!

Which of the following would they give up?

A. Foldable as superclass of Traversable

B. (a,) as Traversable

Personally I think in retrospect I think I'd give up both and use
explicit Traversals (i.e. optics instead).  That way one would have to
write

    allOf each (\ i -> contents p i == contents q i) ...

By contrast

    allOf _2 (\ i -> contents p i == contents q i) ...

obviously looks wrong.

Tom


More information about the Haskell-Cafe mailing list