{-# OPTIONS_GHC -Wno-orphans #-}

module Data.SegTree.RangeAddRangeSum where

import Data.Monoid.RangedSum
import Data.SegTree
import Data.Semigroup

instance (Num a) => AsSemigroupEndo (Sum a) (RangedSum a) where
  sendo :: Sum a -> RangedSum a -> RangedSum a
sendo (Sum a
x) (RangedSum a
len a
y) = a -> a -> RangedSum a
forall a. a -> a -> RangedSum a
RangedSum a
len (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
y)
  {-# INLINE sendo #-}