[Haskell-cafe] Textbook example of instance Foldable ((,) a)
Bryan Richter
b at chreekat.net
Tue Nov 24 13:20:16 UTC 2020
In homage to the ironic phrase "It's technically true, which is the best
kind of true," perhaps we need a superclass TechnicallyFoldable. :D Then
(,) a could be an instance of TechnicallyFoldable but not Foldable ,
tlength could be defined as tlength = length for (Foldable a =>
TechnicallyFoldable a), and anybody who really wants the maximally general
option could always use tlength.
The parallel with fmap speaks for itself. :)
Den tis 24 nov. 2020 11:56Manuel Schneckenreither <manuel.schnecki at gmail.com>
skrev:
> >>>>> "TE" == Tom Ellis <tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk>
> writes:
>
> TE> On Mon, Nov 23, 2020 at 09:54:26PM +0100, Francesco Ariis wrote:
>
> TE> Which of the following would they give up?
>
> TE> A. Foldable as superclass of Traversable
>
> TE> B. (a,) as Traversable
>
> For me it is B. Even the Foldable hackage description states "Functors
> representing data structures that can be traversed from left to right."
> The tuple is however not traversed from left to right, but solely on the
> right (as it's half filled).
>
> For me it doesn't make sense to implement it, just because it's
> implementable. I think the current implementation does not add more
> value than it harms.
>
>
> El lun., 23 nov. 2020 22:23, Tom Ellis <
> tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk> escribió:
>
>> 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
>> _______________________________________________
>> Haskell-Cafe mailing list
>> To (un)subscribe, modify options or view archives go to:
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>> Only members subscribed via the mailman list are allowed to post.
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20201124/316d0237/attachment.html>
More information about the Haskell-Cafe
mailing list