{-# OPTIONS_GHC -Wno-orphans #-}

module Data.SegTree.RangeAffineRangeSum where

import Data.Monoid.Affine
import Data.Monoid.RangedSum
import Data.SegTree

instance (Num a) => AsSemigroupEndo (Affine a) (RangedSum a) where
  sendo :: Affine a -> RangedSum a -> RangedSum a
sendo (Affine a
a a
b) (RangedSum a
len a
x) = a -> a -> RangedSum a
forall a. a -> a -> RangedSum a
RangedSum a
len (a
a a -> a -> a
forall a. Num a => a -> a -> a
* a
x a -> a -> a
forall a. Num a => a -> a -> a
+ a
len a -> a -> a
forall a. Num a => a -> a -> a
* a
b)
  {-# INLINE sendo #-}