{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE TypeFamilies #-}
module Data.Monoid.BitOr where
import Data.Bits
import Data.Coerce (coerce)
import qualified Data.Foldable as F
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed as U
newtype BitOr a = BitOr {forall a. BitOr a -> a
getBitOr :: a}
deriving (BitOr a -> BitOr a -> Bool
(BitOr a -> BitOr a -> Bool)
-> (BitOr a -> BitOr a -> Bool) -> Eq (BitOr a)
forall a. Eq a => BitOr a -> BitOr a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => BitOr a -> BitOr a -> Bool
== :: BitOr a -> BitOr a -> Bool
$c/= :: forall a. Eq a => BitOr a -> BitOr a -> Bool
/= :: BitOr a -> BitOr a -> Bool
Eq, Int -> BitOr a -> ShowS
[BitOr a] -> ShowS
BitOr a -> String
(Int -> BitOr a -> ShowS)
-> (BitOr a -> String) -> ([BitOr a] -> ShowS) -> Show (BitOr a)
forall a. Show a => Int -> BitOr a -> ShowS
forall a. Show a => [BitOr a] -> ShowS
forall a. Show a => BitOr a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> BitOr a -> ShowS
showsPrec :: Int -> BitOr a -> ShowS
$cshow :: forall a. Show a => BitOr a -> String
show :: BitOr a -> String
$cshowList :: forall a. Show a => [BitOr a] -> ShowS
showList :: [BitOr a] -> ShowS
Show)
instance (Bits a) => Semigroup (BitOr a) where
<> :: BitOr a -> BitOr a -> BitOr a
(<>) = (a -> a -> a) -> BitOr a -> BitOr a -> BitOr a
forall a b. Coercible a b => a -> b
coerce (forall a. Bits a => a -> a -> a
(.|.) @a)
{-# INLINE (<>) #-}
instance (Bits a) => Monoid (BitOr a) where
mempty :: BitOr a
mempty = a -> BitOr a
forall a b. Coercible a b => a -> b
coerce (forall a. Bits a => a
zeroBits @a)
{-# INLINE mempty #-}
mconcat :: [BitOr a] -> BitOr a
mconcat = (BitOr a -> BitOr a -> BitOr a) -> BitOr a -> [BitOr a] -> BitOr a
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl' BitOr a -> BitOr a -> BitOr a
forall a. Monoid a => a -> a -> a
mappend BitOr a
forall a. Monoid a => a
mempty
{-# INLINE mconcat #-}
newtype instance U.MVector s (BitOr a) = MV_BitOr (U.MVector s a)
newtype instance U.Vector (BitOr a) = V_BitOr (U.Vector a)
deriving newtype instance (U.Unbox a) => GM.MVector U.MVector (BitOr a)
deriving newtype instance (U.Unbox a) => G.Vector U.Vector (BitOr a)
instance (U.Unbox a) => U.Unbox (BitOr a)