Skip to content

Add 'stimes = fmap . stimes' to Semigroup (Ap f a)

If a user has defined an efficient implementation of stimes @A will it be propagated by Ap f A? Here is the current Semigroup instance of Ap

instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where
        (Ap x) <> (Ap y) = Ap $ liftA2 (<>) x y

The instances don't define default methods (like stimes). Does it make a difference if we add a dedicated "lifting" method for stimes @(Ap f a)?

instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where
  (<>) :: Ap f a -> Ap f a -> Ap f a
  (<>) = liftA2 (<>)

  stimes :: forall b. Integral b => b -> Ap f a -> Ap f a
  stimes = fmap . stimes
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information