@@ -201,6 +201,21 @@ vectorizeLoopsExpr expr = do
201201-- Really we should check this by seeing whether there is an instance for a
202202-- `Commutative` class, or something like that, but for now just pattern-match
203203-- to detect scalar addition as the only monoid we recognize as commutative.
204+ -- Potentially relevant ideas:
205+ -- - Store commutativity or lack of it as a bit on the BaseMonoid object (but
206+ -- get the bit from where?)
207+ -- - Paramterize runWriter by a user-specified flag saying whether the monoid is
208+ -- to be commutative; record that on the RunWriter Hof, and enforce it by
209+ -- type-checking.
210+ -- - Is there a way to automate checking for commutativity via the typeclass
211+ -- system so the user doesn't have to keep writing "commutative" all the time?
212+ -- - Or maybe make commutativity the default, and require an explicit annotation
213+ -- to opt out? (Which mention in the type error)
214+ -- - Alternately, is there a way to parameterize the BaseMonoid class by a
215+ -- Commutativity bit, such that commutative instances implement the class
216+ -- parametrically in that bit, while not-known-to-be-commutative ones only
217+ -- implement the non-commutative version?
218+ -- - Will that bit be visible enough to the compiler to be picked up here?
204219monoidCommutativity :: (EnvReader m ) => BaseMonoid SimpIR n -> m n MonoidCommutes
205220monoidCommutativity monoid = case isAdditionMonoid monoid of
206221 Just () -> return Commutes
0 commit comments