
24 Nov
2020
24 Nov
'20
2:40 p.m.
On Tue, 24 Nov 2020, Viktor Dukhovni wrote:
And of course, when refactoring, instead of moving to a 2-tuple, that brings in possibly unwanted instances, one can instead choose a custom product type, that does not have a Foldable instance:
-- coercible to a 2-tuple if/as needed newtype T2 a b = T2 { _unT2 :: (a, b) } deriving (Eq, Ord, Show)
to give one's 2-tuples exactly the desired instances and no more. This admittedly is not terribly ergonomic.
If people would use custom pair types we would not need Foldable on pairs, at all.