{-# OPTIONS_GHC -Wno-orphans #-}

module Data.SegTree.RangeUpdateRangeMax where

import Data.Coerce
import Data.Monoid.LastMax
import Data.SegTree
import Data.Semigroup

instance
  (Ord a, Bounded a) =>
  AsSemigroupEndo (Dual (LastMax a)) (Max a)
  where
  sendo :: Dual (LastMax a) -> Max a -> Max a
sendo Dual (LastMax a)
x Max a
y
    | Dual (LastMax a)
x Dual (LastMax a) -> Dual (LastMax a) -> Bool
forall a. Eq a => a -> a -> Bool
== Dual (LastMax a)
forall a. Monoid a => a
mempty = Max a
y
    | Bool
otherwise = Dual (LastMax a) -> Max a
forall a b. Coercible a b => a -> b
coerce Dual (LastMax a)
x
  {-# INLINE sendo #-}