Closed axch closed 1 year ago
The same question applies to Eq
and Ix
, though possibly with a different answer, because functions do not have useful a Eq
instance anyway, and while a functional type could be given an Ix
instance, doing so feels artificial.
Let's have Add
require Data
, and likewise for Eq
and Ix
. If we change our minds we can always make them more general, but going in the other direction is hard.
Pro yes: It's well-defined, and easy to implement. (And status quo is they do, but it's almost completely unused in the corpus.)
Pro no: Such an instance would violate the implicit contract that + performs work and produces a result that's the same size as its inputs.
Pro no: It also arguably wouldn't be a first-class instance, because functions aren't fully first-class. In particular, functions cannot be stored in references, so
sum
,cumsum
, and so on cannot work on (arrays of) them anyway.This decision is topical with the upcoming addition of the
Data
constraint (#1150) -- if we decide that functions do not needAdd
, then we can makeAdd
requireData
and save the latter annotation onsum
,cumsum
, etc.Thoughts? Discuss!