{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Trustworthy #-}
module Data.Bits (
Bits(
(.&.), (.|.), xor,
complement,
shift,
rotate,
zeroBits,
bit,
setBit,
clearBit,
complementBit,
testBit,
bitSizeMaybe,
bitSize,
isSigned,
shiftL, shiftR,
unsafeShiftL, unsafeShiftR,
rotateL, rotateR,
popCount
),
FiniteBits(
finiteBitSize,
countLeadingZeros,
countTrailingZeros
),
bitDefault,
testBitDefault,
popCountDefault,
toIntegralSized,
oneBits,
(.^.),
(.>>.), (.<<.), (!>>.), (!<<.),
And(..), Ior(..), Xor(..), Iff(..)
) where
import GHC.Base
import GHC.Bits
import GHC.Enum
import qualified GHC.List as List
import GHC.Read
import GHC.Show
oneBits :: (FiniteBits a) => a
oneBits :: forall a. FiniteBits a => a
oneBits = a -> a
forall a. Bits a => a -> a
complement a
forall a. Bits a => a
zeroBits
{-# INLINE oneBits #-}
(.^.) :: (Bits a) => a -> a -> a
.^. :: forall a. Bits a => a -> a -> a
(.^.) = a -> a -> a
forall a. Bits a => a -> a -> a
xor
infixl 6 .^.
(.>>.) :: (Bits a) => a -> Int -> a
.>>. :: forall a. Bits a => a -> Int -> a
(.>>.) = a -> Int -> a
forall a. Bits a => a -> Int -> a
shiftR
infixl 8 .>>.
(.<<.) :: (Bits a) => a -> Int -> a
.<<. :: forall a. Bits a => a -> Int -> a
(.<<.) = a -> Int -> a
forall a. Bits a => a -> Int -> a
shiftL
infixl 8 .<<.
(!>>.) :: (Bits a) => a -> Int -> a
!>>. :: forall a. Bits a => a -> Int -> a
(!>>.) = a -> Int -> a
forall a. Bits a => a -> Int -> a
unsafeShiftR
infixl 8 !>>.
(!<<.) :: (Bits a) => a -> Int -> a
!<<. :: forall a. Bits a => a -> Int -> a
(!<<.) = a -> Int -> a
forall a. Bits a => a -> Int -> a
unsafeShiftL
infixl 8 !<<.
newtype And a = And { forall a. And a -> a
getAnd :: a }
deriving newtype (
And a
And a -> And a -> Bounded (And a)
forall a. a -> a -> Bounded a
forall a. Bounded a => And a
$cminBound :: forall a. Bounded a => And a
minBound :: And a
$cmaxBound :: forall a. Bounded a => And a
maxBound :: And a
Bounded,
Int -> And a
And a -> Int
And a -> [And a]
And a -> And a
And a -> And a -> [And a]
And a -> And a -> And a -> [And a]
(And a -> And a)
-> (And a -> And a)
-> (Int -> And a)
-> (And a -> Int)
-> (And a -> [And a])
-> (And a -> And a -> [And a])
-> (And a -> And a -> [And a])
-> (And a -> And a -> And a -> [And a])
-> Enum (And a)
forall a. Enum a => Int -> And a
forall a. Enum a => And a -> Int
forall a. Enum a => And a -> [And a]
forall a. Enum a => And a -> And a
forall a. Enum a => And a -> And a -> [And a]
forall a. Enum a => And a -> And a -> And a -> [And a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: forall a. Enum a => And a -> And a
succ :: And a -> And a
$cpred :: forall a. Enum a => And a -> And a
pred :: And a -> And a
$ctoEnum :: forall a. Enum a => Int -> And a
toEnum :: Int -> And a
$cfromEnum :: forall a. Enum a => And a -> Int
fromEnum :: And a -> Int
$cenumFrom :: forall a. Enum a => And a -> [And a]
enumFrom :: And a -> [And a]
$cenumFromThen :: forall a. Enum a => And a -> And a -> [And a]
enumFromThen :: And a -> And a -> [And a]
$cenumFromTo :: forall a. Enum a => And a -> And a -> [And a]
enumFromTo :: And a -> And a -> [And a]
$cenumFromThenTo :: forall a. Enum a => And a -> And a -> And a -> [And a]
enumFromThenTo :: And a -> And a -> And a -> [And a]
Enum,
Eq (And a)
And a
Eq (And a)
-> (And a -> And a -> And a)
-> (And a -> And a -> And a)
-> (And a -> And a -> And a)
-> (And a -> And a)
-> (And a -> Int -> And a)
-> (And a -> Int -> And a)
-> And a
-> (Int -> And a)
-> (And a -> Int -> And a)
-> (And a -> Int -> And a)
-> (And a -> Int -> And a)
-> (And a -> Int -> Bool)
-> (And a -> Maybe Int)
-> (And a -> Int)
-> (And a -> Bool)
-> (And a -> Int -> And a)
-> (And a -> Int -> And a)
-> (And a -> Int -> And a)
-> (And a -> Int -> And a)
-> (And a -> Int -> And a)
-> (And a -> Int -> And a)
-> (And a -> Int)
-> Bits (And a)
Int -> And a
And a -> Bool
And a -> Int
And a -> Maybe Int
And a -> And a
And a -> Int -> Bool
And a -> Int -> And a
And a -> And a -> And a
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
forall {a}. Bits a => Eq (And a)
forall a. Bits a => And a
forall a. Bits a => Int -> And a
forall a. Bits a => And a -> Bool
forall a. Bits a => And a -> Int
forall a. Bits a => And a -> Maybe Int
forall a. Bits a => And a -> And a
forall a. Bits a => And a -> Int -> Bool
forall a. Bits a => And a -> Int -> And a
forall a. Bits a => And a -> And a -> And a
$c.&. :: forall a. Bits a => And a -> And a -> And a
.&. :: And a -> And a -> And a
$c.|. :: forall a. Bits a => And a -> And a -> And a
.|. :: And a -> And a -> And a
$cxor :: forall a. Bits a => And a -> And a -> And a
xor :: And a -> And a -> And a
$ccomplement :: forall a. Bits a => And a -> And a
complement :: And a -> And a
$cshift :: forall a. Bits a => And a -> Int -> And a
shift :: And a -> Int -> And a
$crotate :: forall a. Bits a => And a -> Int -> And a
rotate :: And a -> Int -> And a
$czeroBits :: forall a. Bits a => And a
zeroBits :: And a
$cbit :: forall a. Bits a => Int -> And a
bit :: Int -> And a
$csetBit :: forall a. Bits a => And a -> Int -> And a
setBit :: And a -> Int -> And a
$cclearBit :: forall a. Bits a => And a -> Int -> And a
clearBit :: And a -> Int -> And a
$ccomplementBit :: forall a. Bits a => And a -> Int -> And a
complementBit :: And a -> Int -> And a
$ctestBit :: forall a. Bits a => And a -> Int -> Bool
testBit :: And a -> Int -> Bool
$cbitSizeMaybe :: forall a. Bits a => And a -> Maybe Int
bitSizeMaybe :: And a -> Maybe Int
$cbitSize :: forall a. Bits a => And a -> Int
bitSize :: And a -> Int
$cisSigned :: forall a. Bits a => And a -> Bool
isSigned :: And a -> Bool
$cshiftL :: forall a. Bits a => And a -> Int -> And a
shiftL :: And a -> Int -> And a
$cunsafeShiftL :: forall a. Bits a => And a -> Int -> And a
unsafeShiftL :: And a -> Int -> And a
$cshiftR :: forall a. Bits a => And a -> Int -> And a
shiftR :: And a -> Int -> And a
$cunsafeShiftR :: forall a. Bits a => And a -> Int -> And a
unsafeShiftR :: And a -> Int -> And a
$crotateL :: forall a. Bits a => And a -> Int -> And a
rotateL :: And a -> Int -> And a
$crotateR :: forall a. Bits a => And a -> Int -> And a
rotateR :: And a -> Int -> And a
$cpopCount :: forall a. Bits a => And a -> Int
popCount :: And a -> Int
Bits,
Bits (And a)
Bits (And a)
-> (And a -> Int)
-> (And a -> Int)
-> (And a -> Int)
-> FiniteBits (And a)
And a -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
forall {a}. FiniteBits a => Bits (And a)
forall a. FiniteBits a => And a -> Int
$cfiniteBitSize :: forall a. FiniteBits a => And a -> Int
finiteBitSize :: And a -> Int
$ccountLeadingZeros :: forall a. FiniteBits a => And a -> Int
countLeadingZeros :: And a -> Int
$ccountTrailingZeros :: forall a. FiniteBits a => And a -> Int
countTrailingZeros :: And a -> Int
FiniteBits,
And a -> And a -> Bool
(And a -> And a -> Bool) -> (And a -> And a -> Bool) -> Eq (And a)
forall a. Eq a => And a -> And a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => And a -> And a -> Bool
== :: And a -> And a -> Bool
$c/= :: forall a. Eq a => And a -> And a -> Bool
/= :: And a -> And a -> Bool
Eq
)
deriving stock (
Int -> And a -> ShowS
[And a] -> ShowS
And a -> String
(Int -> And a -> ShowS)
-> (And a -> String) -> ([And a] -> ShowS) -> Show (And a)
forall a. Show a => Int -> And a -> ShowS
forall a. Show a => [And a] -> ShowS
forall a. Show a => And a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> And a -> ShowS
showsPrec :: Int -> And a -> ShowS
$cshow :: forall a. Show a => And a -> String
show :: And a -> String
$cshowList :: forall a. Show a => [And a] -> ShowS
showList :: [And a] -> ShowS
Show,
ReadPrec [And a]
ReadPrec (And a)
Int -> ReadS (And a)
ReadS [And a]
(Int -> ReadS (And a))
-> ReadS [And a]
-> ReadPrec (And a)
-> ReadPrec [And a]
-> Read (And a)
forall a. Read a => ReadPrec [And a]
forall a. Read a => ReadPrec (And a)
forall a. Read a => Int -> ReadS (And a)
forall a. Read a => ReadS [And a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Read a => Int -> ReadS (And a)
readsPrec :: Int -> ReadS (And a)
$creadList :: forall a. Read a => ReadS [And a]
readList :: ReadS [And a]
$creadPrec :: forall a. Read a => ReadPrec (And a)
readPrec :: ReadPrec (And a)
$creadListPrec :: forall a. Read a => ReadPrec [And a]
readListPrec :: ReadPrec [And a]
Read
)
instance (Bits a) => Semigroup (And a) where
And a
x <> :: And a -> And a -> And a
<> And a
y = a -> And a
forall a. a -> And a
And (a
x a -> a -> a
forall a. Bits a => a -> a -> a
.&. a
y)
instance (FiniteBits a) => Monoid (And a) where
mempty :: And a
mempty = a -> And a
forall a. a -> And a
And a
forall a. FiniteBits a => a
oneBits
mconcat :: [And a] -> And a
mconcat = (And a -> And a -> And a) -> And a -> [And a] -> And a
forall a b. (b -> a -> b) -> b -> [a] -> b
List.foldl' And a -> And a -> And a
forall a. Semigroup a => a -> a -> a
(<>) And a
forall a. Monoid a => a
mempty
{-# INLINE mconcat #-}
newtype Ior a = Ior { forall a. Ior a -> a
getIor :: a }
deriving newtype (
Ior a
Ior a -> Ior a -> Bounded (Ior a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Ior a
$cminBound :: forall a. Bounded a => Ior a
minBound :: Ior a
$cmaxBound :: forall a. Bounded a => Ior a
maxBound :: Ior a
Bounded,
Int -> Ior a
Ior a -> Int
Ior a -> [Ior a]
Ior a -> Ior a
Ior a -> Ior a -> [Ior a]
Ior a -> Ior a -> Ior a -> [Ior a]
(Ior a -> Ior a)
-> (Ior a -> Ior a)
-> (Int -> Ior a)
-> (Ior a -> Int)
-> (Ior a -> [Ior a])
-> (Ior a -> Ior a -> [Ior a])
-> (Ior a -> Ior a -> [Ior a])
-> (Ior a -> Ior a -> Ior a -> [Ior a])
-> Enum (Ior a)
forall a. Enum a => Int -> Ior a
forall a. Enum a => Ior a -> Int
forall a. Enum a => Ior a -> [Ior a]
forall a. Enum a => Ior a -> Ior a
forall a. Enum a => Ior a -> Ior a -> [Ior a]
forall a. Enum a => Ior a -> Ior a -> Ior a -> [Ior a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: forall a. Enum a => Ior a -> Ior a
succ :: Ior a -> Ior a
$cpred :: forall a. Enum a => Ior a -> Ior a
pred :: Ior a -> Ior a
$ctoEnum :: forall a. Enum a => Int -> Ior a
toEnum :: Int -> Ior a
$cfromEnum :: forall a. Enum a => Ior a -> Int
fromEnum :: Ior a -> Int
$cenumFrom :: forall a. Enum a => Ior a -> [Ior a]
enumFrom :: Ior a -> [Ior a]
$cenumFromThen :: forall a. Enum a => Ior a -> Ior a -> [Ior a]
enumFromThen :: Ior a -> Ior a -> [Ior a]
$cenumFromTo :: forall a. Enum a => Ior a -> Ior a -> [Ior a]
enumFromTo :: Ior a -> Ior a -> [Ior a]
$cenumFromThenTo :: forall a. Enum a => Ior a -> Ior a -> Ior a -> [Ior a]
enumFromThenTo :: Ior a -> Ior a -> Ior a -> [Ior a]
Enum,
Eq (Ior a)
Ior a
Eq (Ior a)
-> (Ior a -> Ior a -> Ior a)
-> (Ior a -> Ior a -> Ior a)
-> (Ior a -> Ior a -> Ior a)
-> (Ior a -> Ior a)
-> (Ior a -> Int -> Ior a)
-> (Ior a -> Int -> Ior a)
-> Ior a
-> (Int -> Ior a)
-> (Ior a -> Int -> Ior a)
-> (Ior a -> Int -> Ior a)
-> (Ior a -> Int -> Ior a)
-> (Ior a -> Int -> Bool)
-> (Ior a -> Maybe Int)
-> (Ior a -> Int)
-> (Ior a -> Bool)
-> (Ior a -> Int -> Ior a)
-> (Ior a -> Int -> Ior a)
-> (Ior a -> Int -> Ior a)
-> (Ior a -> Int -> Ior a)
-> (Ior a -> Int -> Ior a)
-> (Ior a -> Int -> Ior a)
-> (Ior a -> Int)
-> Bits (Ior a)
Int -> Ior a
Ior a -> Bool
Ior a -> Int
Ior a -> Maybe Int
Ior a -> Ior a
Ior a -> Int -> Bool
Ior a -> Int -> Ior a
Ior a -> Ior a -> Ior a
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
forall {a}. Bits a => Eq (Ior a)
forall a. Bits a => Ior a
forall a. Bits a => Int -> Ior a
forall a. Bits a => Ior a -> Bool
forall a. Bits a => Ior a -> Int
forall a. Bits a => Ior a -> Maybe Int
forall a. Bits a => Ior a -> Ior a
forall a. Bits a => Ior a -> Int -> Bool
forall a. Bits a => Ior a -> Int -> Ior a
forall a. Bits a => Ior a -> Ior a -> Ior a
$c.&. :: forall a. Bits a => Ior a -> Ior a -> Ior a
.&. :: Ior a -> Ior a -> Ior a
$c.|. :: forall a. Bits a => Ior a -> Ior a -> Ior a
.|. :: Ior a -> Ior a -> Ior a
$cxor :: forall a. Bits a => Ior a -> Ior a -> Ior a
xor :: Ior a -> Ior a -> Ior a
$ccomplement :: forall a. Bits a => Ior a -> Ior a
complement :: Ior a -> Ior a
$cshift :: forall a. Bits a => Ior a -> Int -> Ior a
shift :: Ior a -> Int -> Ior a
$crotate :: forall a. Bits a => Ior a -> Int -> Ior a
rotate :: Ior a -> Int -> Ior a
$czeroBits :: forall a. Bits a => Ior a
zeroBits :: Ior a
$cbit :: forall a. Bits a => Int -> Ior a
bit :: Int -> Ior a
$csetBit :: forall a. Bits a => Ior a -> Int -> Ior a
setBit :: Ior a -> Int -> Ior a
$cclearBit :: forall a. Bits a => Ior a -> Int -> Ior a
clearBit :: Ior a -> Int -> Ior a
$ccomplementBit :: forall a. Bits a => Ior a -> Int -> Ior a
complementBit :: Ior a -> Int -> Ior a
$ctestBit :: forall a. Bits a => Ior a -> Int -> Bool
testBit :: Ior a -> Int -> Bool
$cbitSizeMaybe :: forall a. Bits a => Ior a -> Maybe Int
bitSizeMaybe :: Ior a -> Maybe Int
$cbitSize :: forall a. Bits a => Ior a -> Int
bitSize :: Ior a -> Int
$cisSigned :: forall a. Bits a => Ior a -> Bool
isSigned :: Ior a -> Bool
$cshiftL :: forall a. Bits a => Ior a -> Int -> Ior a
shiftL :: Ior a -> Int -> Ior a
$cunsafeShiftL :: forall a. Bits a => Ior a -> Int -> Ior a
unsafeShiftL :: Ior a -> Int -> Ior a
$cshiftR :: forall a. Bits a => Ior a -> Int -> Ior a
shiftR :: Ior a -> Int -> Ior a
$cunsafeShiftR :: forall a. Bits a => Ior a -> Int -> Ior a
unsafeShiftR :: Ior a -> Int -> Ior a
$crotateL :: forall a. Bits a => Ior a -> Int -> Ior a
rotateL :: Ior a -> Int -> Ior a
$crotateR :: forall a. Bits a => Ior a -> Int -> Ior a
rotateR :: Ior a -> Int -> Ior a
$cpopCount :: forall a. Bits a => Ior a -> Int
popCount :: Ior a -> Int
Bits,
Bits (Ior a)
Bits (Ior a)
-> (Ior a -> Int)
-> (Ior a -> Int)
-> (Ior a -> Int)
-> FiniteBits (Ior a)
Ior a -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
forall {a}. FiniteBits a => Bits (Ior a)
forall a. FiniteBits a => Ior a -> Int
$cfiniteBitSize :: forall a. FiniteBits a => Ior a -> Int
finiteBitSize :: Ior a -> Int
$ccountLeadingZeros :: forall a. FiniteBits a => Ior a -> Int
countLeadingZeros :: Ior a -> Int
$ccountTrailingZeros :: forall a. FiniteBits a => Ior a -> Int
countTrailingZeros :: Ior a -> Int
FiniteBits,
Ior a -> Ior a -> Bool
(Ior a -> Ior a -> Bool) -> (Ior a -> Ior a -> Bool) -> Eq (Ior a)
forall a. Eq a => Ior a -> Ior a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Ior a -> Ior a -> Bool
== :: Ior a -> Ior a -> Bool
$c/= :: forall a. Eq a => Ior a -> Ior a -> Bool
/= :: Ior a -> Ior a -> Bool
Eq
)
deriving stock (
Int -> Ior a -> ShowS
[Ior a] -> ShowS
Ior a -> String
(Int -> Ior a -> ShowS)
-> (Ior a -> String) -> ([Ior a] -> ShowS) -> Show (Ior a)
forall a. Show a => Int -> Ior a -> ShowS
forall a. Show a => [Ior a] -> ShowS
forall a. Show a => Ior a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Ior a -> ShowS
showsPrec :: Int -> Ior a -> ShowS
$cshow :: forall a. Show a => Ior a -> String
show :: Ior a -> String
$cshowList :: forall a. Show a => [Ior a] -> ShowS
showList :: [Ior a] -> ShowS
Show,
ReadPrec [Ior a]
ReadPrec (Ior a)
Int -> ReadS (Ior a)
ReadS [Ior a]
(Int -> ReadS (Ior a))
-> ReadS [Ior a]
-> ReadPrec (Ior a)
-> ReadPrec [Ior a]
-> Read (Ior a)
forall a. Read a => ReadPrec [Ior a]
forall a. Read a => ReadPrec (Ior a)
forall a. Read a => Int -> ReadS (Ior a)
forall a. Read a => ReadS [Ior a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Read a => Int -> ReadS (Ior a)
readsPrec :: Int -> ReadS (Ior a)
$creadList :: forall a. Read a => ReadS [Ior a]
readList :: ReadS [Ior a]
$creadPrec :: forall a. Read a => ReadPrec (Ior a)
readPrec :: ReadPrec (Ior a)
$creadListPrec :: forall a. Read a => ReadPrec [Ior a]
readListPrec :: ReadPrec [Ior a]
Read
)
instance (Bits a) => Semigroup (Ior a) where
Ior a
x <> :: Ior a -> Ior a -> Ior a
<> Ior a
y = a -> Ior a
forall a. a -> Ior a
Ior (a
x a -> a -> a
forall a. Bits a => a -> a -> a
.|. a
y)
instance (Bits a) => Monoid (Ior a) where
mempty :: Ior a
mempty = a -> Ior a
forall a. a -> Ior a
Ior a
forall a. Bits a => a
zeroBits
mconcat :: [Ior a] -> Ior a
mconcat = (Ior a -> Ior a -> Ior a) -> Ior a -> [Ior a] -> Ior a
forall a b. (b -> a -> b) -> b -> [a] -> b
List.foldl' Ior a -> Ior a -> Ior a
forall a. Semigroup a => a -> a -> a
(<>) Ior a
forall a. Monoid a => a
mempty
{-# INLINE mconcat #-}
newtype Xor a = Xor { forall a. Xor a -> a
getXor :: a }
deriving newtype (
Xor a
Xor a -> Xor a -> Bounded (Xor a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Xor a
$cminBound :: forall a. Bounded a => Xor a
minBound :: Xor a
$cmaxBound :: forall a. Bounded a => Xor a
maxBound :: Xor a
Bounded,
Int -> Xor a
Xor a -> Int
Xor a -> [Xor a]
Xor a -> Xor a
Xor a -> Xor a -> [Xor a]
Xor a -> Xor a -> Xor a -> [Xor a]
(Xor a -> Xor a)
-> (Xor a -> Xor a)
-> (Int -> Xor a)
-> (Xor a -> Int)
-> (Xor a -> [Xor a])
-> (Xor a -> Xor a -> [Xor a])
-> (Xor a -> Xor a -> [Xor a])
-> (Xor a -> Xor a -> Xor a -> [Xor a])
-> Enum (Xor a)
forall a. Enum a => Int -> Xor a
forall a. Enum a => Xor a -> Int
forall a. Enum a => Xor a -> [Xor a]
forall a. Enum a => Xor a -> Xor a
forall a. Enum a => Xor a -> Xor a -> [Xor a]
forall a. Enum a => Xor a -> Xor a -> Xor a -> [Xor a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: forall a. Enum a => Xor a -> Xor a
succ :: Xor a -> Xor a
$cpred :: forall a. Enum a => Xor a -> Xor a
pred :: Xor a -> Xor a
$ctoEnum :: forall a. Enum a => Int -> Xor a
toEnum :: Int -> Xor a
$cfromEnum :: forall a. Enum a => Xor a -> Int
fromEnum :: Xor a -> Int
$cenumFrom :: forall a. Enum a => Xor a -> [Xor a]
enumFrom :: Xor a -> [Xor a]
$cenumFromThen :: forall a. Enum a => Xor a -> Xor a -> [Xor a]
enumFromThen :: Xor a -> Xor a -> [Xor a]
$cenumFromTo :: forall a. Enum a => Xor a -> Xor a -> [Xor a]
enumFromTo :: Xor a -> Xor a -> [Xor a]
$cenumFromThenTo :: forall a. Enum a => Xor a -> Xor a -> Xor a -> [Xor a]
enumFromThenTo :: Xor a -> Xor a -> Xor a -> [Xor a]
Enum,
Eq (Xor a)
Xor a
Eq (Xor a)
-> (Xor a -> Xor a -> Xor a)
-> (Xor a -> Xor a -> Xor a)
-> (Xor a -> Xor a -> Xor a)
-> (Xor a -> Xor a)
-> (Xor a -> Int -> Xor a)
-> (Xor a -> Int -> Xor a)
-> Xor a
-> (Int -> Xor a)
-> (Xor a -> Int -> Xor a)
-> (Xor a -> Int -> Xor a)
-> (Xor a -> Int -> Xor a)
-> (Xor a -> Int -> Bool)
-> (Xor a -> Maybe Int)
-> (Xor a -> Int)
-> (Xor a -> Bool)
-> (Xor a -> Int -> Xor a)
-> (Xor a -> Int -> Xor a)
-> (Xor a -> Int -> Xor a)
-> (Xor a -> Int -> Xor a)
-> (Xor a -> Int -> Xor a)
-> (Xor a -> Int -> Xor a)
-> (Xor a -> Int)
-> Bits (Xor a)
Int -> Xor a
Xor a -> Bool
Xor a -> Int
Xor a -> Maybe Int
Xor a -> Xor a
Xor a -> Int -> Bool
Xor a -> Int -> Xor a
Xor a -> Xor a -> Xor a
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
forall {a}. Bits a => Eq (Xor a)
forall a. Bits a => Xor a
forall a. Bits a => Int -> Xor a
forall a. Bits a => Xor a -> Bool
forall a. Bits a => Xor a -> Int
forall a. Bits a => Xor a -> Maybe Int
forall a. Bits a => Xor a -> Xor a
forall a. Bits a => Xor a -> Int -> Bool
forall a. Bits a => Xor a -> Int -> Xor a
forall a. Bits a => Xor a -> Xor a -> Xor a
$c.&. :: forall a. Bits a => Xor a -> Xor a -> Xor a
.&. :: Xor a -> Xor a -> Xor a
$c.|. :: forall a. Bits a => Xor a -> Xor a -> Xor a
.|. :: Xor a -> Xor a -> Xor a
$cxor :: forall a. Bits a => Xor a -> Xor a -> Xor a
xor :: Xor a -> Xor a -> Xor a
$ccomplement :: forall a. Bits a => Xor a -> Xor a
complement :: Xor a -> Xor a
$cshift :: forall a. Bits a => Xor a -> Int -> Xor a
shift :: Xor a -> Int -> Xor a
$crotate :: forall a. Bits a => Xor a -> Int -> Xor a
rotate :: Xor a -> Int -> Xor a
$czeroBits :: forall a. Bits a => Xor a
zeroBits :: Xor a
$cbit :: forall a. Bits a => Int -> Xor a
bit :: Int -> Xor a
$csetBit :: forall a. Bits a => Xor a -> Int -> Xor a
setBit :: Xor a -> Int -> Xor a
$cclearBit :: forall a. Bits a => Xor a -> Int -> Xor a
clearBit :: Xor a -> Int -> Xor a
$ccomplementBit :: forall a. Bits a => Xor a -> Int -> Xor a
complementBit :: Xor a -> Int -> Xor a
$ctestBit :: forall a. Bits a => Xor a -> Int -> Bool
testBit :: Xor a -> Int -> Bool
$cbitSizeMaybe :: forall a. Bits a => Xor a -> Maybe Int
bitSizeMaybe :: Xor a -> Maybe Int
$cbitSize :: forall a. Bits a => Xor a -> Int
bitSize :: Xor a -> Int
$cisSigned :: forall a. Bits a => Xor a -> Bool
isSigned :: Xor a -> Bool
$cshiftL :: forall a. Bits a => Xor a -> Int -> Xor a
shiftL :: Xor a -> Int -> Xor a
$cunsafeShiftL :: forall a. Bits a => Xor a -> Int -> Xor a
unsafeShiftL :: Xor a -> Int -> Xor a
$cshiftR :: forall a. Bits a => Xor a -> Int -> Xor a
shiftR :: Xor a -> Int -> Xor a
$cunsafeShiftR :: forall a. Bits a => Xor a -> Int -> Xor a
unsafeShiftR :: Xor a -> Int -> Xor a
$crotateL :: forall a. Bits a => Xor a -> Int -> Xor a
rotateL :: Xor a -> Int -> Xor a
$crotateR :: forall a. Bits a => Xor a -> Int -> Xor a
rotateR :: Xor a -> Int -> Xor a
$cpopCount :: forall a. Bits a => Xor a -> Int
popCount :: Xor a -> Int
Bits,
Bits (Xor a)
Bits (Xor a)
-> (Xor a -> Int)
-> (Xor a -> Int)
-> (Xor a -> Int)
-> FiniteBits (Xor a)
Xor a -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
forall {a}. FiniteBits a => Bits (Xor a)
forall a. FiniteBits a => Xor a -> Int
$cfiniteBitSize :: forall a. FiniteBits a => Xor a -> Int
finiteBitSize :: Xor a -> Int
$ccountLeadingZeros :: forall a. FiniteBits a => Xor a -> Int
countLeadingZeros :: Xor a -> Int
$ccountTrailingZeros :: forall a. FiniteBits a => Xor a -> Int
countTrailingZeros :: Xor a -> Int
FiniteBits,
Xor a -> Xor a -> Bool
(Xor a -> Xor a -> Bool) -> (Xor a -> Xor a -> Bool) -> Eq (Xor a)
forall a. Eq a => Xor a -> Xor a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Xor a -> Xor a -> Bool
== :: Xor a -> Xor a -> Bool
$c/= :: forall a. Eq a => Xor a -> Xor a -> Bool
/= :: Xor a -> Xor a -> Bool
Eq
)
deriving stock (
Int -> Xor a -> ShowS
[Xor a] -> ShowS
Xor a -> String
(Int -> Xor a -> ShowS)
-> (Xor a -> String) -> ([Xor a] -> ShowS) -> Show (Xor a)
forall a. Show a => Int -> Xor a -> ShowS
forall a. Show a => [Xor a] -> ShowS
forall a. Show a => Xor a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Xor a -> ShowS
showsPrec :: Int -> Xor a -> ShowS
$cshow :: forall a. Show a => Xor a -> String
show :: Xor a -> String
$cshowList :: forall a. Show a => [Xor a] -> ShowS
showList :: [Xor a] -> ShowS
Show,
ReadPrec [Xor a]
ReadPrec (Xor a)
Int -> ReadS (Xor a)
ReadS [Xor a]
(Int -> ReadS (Xor a))
-> ReadS [Xor a]
-> ReadPrec (Xor a)
-> ReadPrec [Xor a]
-> Read (Xor a)
forall a. Read a => ReadPrec [Xor a]
forall a. Read a => ReadPrec (Xor a)
forall a. Read a => Int -> ReadS (Xor a)
forall a. Read a => ReadS [Xor a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Read a => Int -> ReadS (Xor a)
readsPrec :: Int -> ReadS (Xor a)
$creadList :: forall a. Read a => ReadS [Xor a]
readList :: ReadS [Xor a]
$creadPrec :: forall a. Read a => ReadPrec (Xor a)
readPrec :: ReadPrec (Xor a)
$creadListPrec :: forall a. Read a => ReadPrec [Xor a]
readListPrec :: ReadPrec [Xor a]
Read
)
instance (Bits a) => Semigroup (Xor a) where
Xor a
x <> :: Xor a -> Xor a -> Xor a
<> Xor a
y = a -> Xor a
forall a. a -> Xor a
Xor (a
x a -> a -> a
forall a. Bits a => a -> a -> a
`xor` a
y)
instance (Bits a) => Monoid (Xor a) where
mempty :: Xor a
mempty = a -> Xor a
forall a. a -> Xor a
Xor a
forall a. Bits a => a
zeroBits
mconcat :: [Xor a] -> Xor a
mconcat = (Xor a -> Xor a -> Xor a) -> Xor a -> [Xor a] -> Xor a
forall a b. (b -> a -> b) -> b -> [a] -> b
List.foldl' Xor a -> Xor a -> Xor a
forall a. Semigroup a => a -> a -> a
(<>) Xor a
forall a. Monoid a => a
mempty
{-# INLINE mconcat #-}
newtype Iff a = Iff { forall a. Iff a -> a
getIff :: a }
deriving newtype (
Iff a
Iff a -> Iff a -> Bounded (Iff a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Iff a
$cminBound :: forall a. Bounded a => Iff a
minBound :: Iff a
$cmaxBound :: forall a. Bounded a => Iff a
maxBound :: Iff a
Bounded,
Int -> Iff a
Iff a -> Int
Iff a -> [Iff a]
Iff a -> Iff a
Iff a -> Iff a -> [Iff a]
Iff a -> Iff a -> Iff a -> [Iff a]
(Iff a -> Iff a)
-> (Iff a -> Iff a)
-> (Int -> Iff a)
-> (Iff a -> Int)
-> (Iff a -> [Iff a])
-> (Iff a -> Iff a -> [Iff a])
-> (Iff a -> Iff a -> [Iff a])
-> (Iff a -> Iff a -> Iff a -> [Iff a])
-> Enum (Iff a)
forall a. Enum a => Int -> Iff a
forall a. Enum a => Iff a -> Int
forall a. Enum a => Iff a -> [Iff a]
forall a. Enum a => Iff a -> Iff a
forall a. Enum a => Iff a -> Iff a -> [Iff a]
forall a. Enum a => Iff a -> Iff a -> Iff a -> [Iff a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: forall a. Enum a => Iff a -> Iff a
succ :: Iff a -> Iff a
$cpred :: forall a. Enum a => Iff a -> Iff a
pred :: Iff a -> Iff a
$ctoEnum :: forall a. Enum a => Int -> Iff a
toEnum :: Int -> Iff a
$cfromEnum :: forall a. Enum a => Iff a -> Int
fromEnum :: Iff a -> Int
$cenumFrom :: forall a. Enum a => Iff a -> [Iff a]
enumFrom :: Iff a -> [Iff a]
$cenumFromThen :: forall a. Enum a => Iff a -> Iff a -> [Iff a]
enumFromThen :: Iff a -> Iff a -> [Iff a]
$cenumFromTo :: forall a. Enum a => Iff a -> Iff a -> [Iff a]
enumFromTo :: Iff a -> Iff a -> [Iff a]
$cenumFromThenTo :: forall a. Enum a => Iff a -> Iff a -> Iff a -> [Iff a]
enumFromThenTo :: Iff a -> Iff a -> Iff a -> [Iff a]
Enum,
Eq (Iff a)
Iff a
Eq (Iff a)
-> (Iff a -> Iff a -> Iff a)
-> (Iff a -> Iff a -> Iff a)
-> (Iff a -> Iff a -> Iff a)
-> (Iff a -> Iff a)
-> (Iff a -> Int -> Iff a)
-> (Iff a -> Int -> Iff a)
-> Iff a
-> (Int -> Iff a)
-> (Iff a -> Int -> Iff a)
-> (Iff a -> Int -> Iff a)
-> (Iff a -> Int -> Iff a)
-> (Iff a -> Int -> Bool)
-> (Iff a -> Maybe Int)
-> (Iff a -> Int)
-> (Iff a -> Bool)
-> (Iff a -> Int -> Iff a)
-> (Iff a -> Int -> Iff a)
-> (Iff a -> Int -> Iff a)
-> (Iff a -> Int -> Iff a)
-> (Iff a -> Int -> Iff a)
-> (Iff a -> Int -> Iff a)
-> (Iff a -> Int)
-> Bits (Iff a)
Int -> Iff a
Iff a -> Bool
Iff a -> Int
Iff a -> Maybe Int
Iff a -> Iff a
Iff a -> Int -> Bool
Iff a -> Int -> Iff a
Iff a -> Iff a -> Iff a
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
forall {a}. Bits a => Eq (Iff a)
forall a. Bits a => Iff a
forall a. Bits a => Int -> Iff a
forall a. Bits a => Iff a -> Bool
forall a. Bits a => Iff a -> Int
forall a. Bits a => Iff a -> Maybe Int
forall a. Bits a => Iff a -> Iff a
forall a. Bits a => Iff a -> Int -> Bool
forall a. Bits a => Iff a -> Int -> Iff a
forall a. Bits a => Iff a -> Iff a -> Iff a
$c.&. :: forall a. Bits a => Iff a -> Iff a -> Iff a
.&. :: Iff a -> Iff a -> Iff a
$c.|. :: forall a. Bits a => Iff a -> Iff a -> Iff a
.|. :: Iff a -> Iff a -> Iff a
$cxor :: forall a. Bits a => Iff a -> Iff a -> Iff a
xor :: Iff a -> Iff a -> Iff a
$ccomplement :: forall a. Bits a => Iff a -> Iff a
complement :: Iff a -> Iff a
$cshift :: forall a. Bits a => Iff a -> Int -> Iff a
shift :: Iff a -> Int -> Iff a
$crotate :: forall a. Bits a => Iff a -> Int -> Iff a
rotate :: Iff a -> Int -> Iff a
$czeroBits :: forall a. Bits a => Iff a
zeroBits :: Iff a
$cbit :: forall a. Bits a => Int -> Iff a
bit :: Int -> Iff a
$csetBit :: forall a. Bits a => Iff a -> Int -> Iff a
setBit :: Iff a -> Int -> Iff a
$cclearBit :: forall a. Bits a => Iff a -> Int -> Iff a
clearBit :: Iff a -> Int -> Iff a
$ccomplementBit :: forall a. Bits a => Iff a -> Int -> Iff a
complementBit :: Iff a -> Int -> Iff a
$ctestBit :: forall a. Bits a => Iff a -> Int -> Bool
testBit :: Iff a -> Int -> Bool
$cbitSizeMaybe :: forall a. Bits a => Iff a -> Maybe Int
bitSizeMaybe :: Iff a -> Maybe Int
$cbitSize :: forall a. Bits a => Iff a -> Int
bitSize :: Iff a -> Int
$cisSigned :: forall a. Bits a => Iff a -> Bool
isSigned :: Iff a -> Bool
$cshiftL :: forall a. Bits a => Iff a -> Int -> Iff a
shiftL :: Iff a -> Int -> Iff a
$cunsafeShiftL :: forall a. Bits a => Iff a -> Int -> Iff a
unsafeShiftL :: Iff a -> Int -> Iff a
$cshiftR :: forall a. Bits a => Iff a -> Int -> Iff a
shiftR :: Iff a -> Int -> Iff a
$cunsafeShiftR :: forall a. Bits a => Iff a -> Int -> Iff a
unsafeShiftR :: Iff a -> Int -> Iff a
$crotateL :: forall a. Bits a => Iff a -> Int -> Iff a
rotateL :: Iff a -> Int -> Iff a
$crotateR :: forall a. Bits a => Iff a -> Int -> Iff a
rotateR :: Iff a -> Int -> Iff a
$cpopCount :: forall a. Bits a => Iff a -> Int
popCount :: Iff a -> Int
Bits,
Bits (Iff a)
Bits (Iff a)
-> (Iff a -> Int)
-> (Iff a -> Int)
-> (Iff a -> Int)
-> FiniteBits (Iff a)
Iff a -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
forall {a}. FiniteBits a => Bits (Iff a)
forall a. FiniteBits a => Iff a -> Int
$cfiniteBitSize :: forall a. FiniteBits a => Iff a -> Int
finiteBitSize :: Iff a -> Int
$ccountLeadingZeros :: forall a. FiniteBits a => Iff a -> Int
countLeadingZeros :: Iff a -> Int
$ccountTrailingZeros :: forall a. FiniteBits a => Iff a -> Int
countTrailingZeros :: Iff a -> Int
FiniteBits,
Iff a -> Iff a -> Bool
(Iff a -> Iff a -> Bool) -> (Iff a -> Iff a -> Bool) -> Eq (Iff a)
forall a. Eq a => Iff a -> Iff a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Iff a -> Iff a -> Bool
== :: Iff a -> Iff a -> Bool
$c/= :: forall a. Eq a => Iff a -> Iff a -> Bool
/= :: Iff a -> Iff a -> Bool
Eq
)
deriving stock (
Int -> Iff a -> ShowS
[Iff a] -> ShowS
Iff a -> String
(Int -> Iff a -> ShowS)
-> (Iff a -> String) -> ([Iff a] -> ShowS) -> Show (Iff a)
forall a. Show a => Int -> Iff a -> ShowS
forall a. Show a => [Iff a] -> ShowS
forall a. Show a => Iff a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Iff a -> ShowS
showsPrec :: Int -> Iff a -> ShowS
$cshow :: forall a. Show a => Iff a -> String
show :: Iff a -> String
$cshowList :: forall a. Show a => [Iff a] -> ShowS
showList :: [Iff a] -> ShowS
Show,
ReadPrec [Iff a]
ReadPrec (Iff a)
Int -> ReadS (Iff a)
ReadS [Iff a]
(Int -> ReadS (Iff a))
-> ReadS [Iff a]
-> ReadPrec (Iff a)
-> ReadPrec [Iff a]
-> Read (Iff a)
forall a. Read a => ReadPrec [Iff a]
forall a. Read a => ReadPrec (Iff a)
forall a. Read a => Int -> ReadS (Iff a)
forall a. Read a => ReadS [Iff a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Read a => Int -> ReadS (Iff a)
readsPrec :: Int -> ReadS (Iff a)
$creadList :: forall a. Read a => ReadS [Iff a]
readList :: ReadS [Iff a]
$creadPrec :: forall a. Read a => ReadPrec (Iff a)
readPrec :: ReadPrec (Iff a)
$creadListPrec :: forall a. Read a => ReadPrec [Iff a]
readListPrec :: ReadPrec [Iff a]
Read
)
instance (FiniteBits a) => Semigroup (Iff a) where
Iff a
x <> :: Iff a -> Iff a -> Iff a
<> Iff a
y = a -> Iff a
forall a. a -> Iff a
Iff (a -> Iff a) -> (a -> a) -> a -> Iff a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a
forall a. Bits a => a -> a
complement (a -> Iff a) -> a -> Iff a
forall a b. (a -> b) -> a -> b
$ (a
x a -> a -> a
forall a. Bits a => a -> a -> a
`xor` a
y)
instance (FiniteBits a) => Monoid (Iff a) where
mempty :: Iff a
mempty = a -> Iff a
forall a. a -> Iff a
Iff a
forall a. FiniteBits a => a
oneBits
mconcat :: [Iff a] -> Iff a
mconcat = (Iff a -> Iff a -> Iff a) -> Iff a -> [Iff a] -> Iff a
forall a b. (b -> a -> b) -> b -> [a] -> b
List.foldl' Iff a -> Iff a -> Iff a
forall a. Semigroup a => a -> a -> a
(<>) Iff a
forall a. Monoid a => a
mempty
{-# INLINE mconcat #-}