    {-# LANGUAGE DerivingStrategies #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE NoImplicitPrelude #-}
    {-# LANGUAGE Trustworthy #-}

    -----------------------------------------------------------------------------
    -- |
    -- Module      :  Data.Bits
    -- Copyright   :  (c) The University of Glasgow 2001
    -- License     :  BSD-style (see the file libraries/base/LICENSE)
    --
    -- Maintainer  :  libraries@haskell.org
    -- Stability   :  experimental
    -- Portability :  portable
    --
    -- This module defines bitwise operations for signed and unsigned
    -- integers.  Instances of the class 'Bits' for the 'Int' and
    -- 'Integer' types are available from this module, and instances for
    -- explicitly sized integral types are available from the
    -- "Data.Int" and "Data.Word" modules.
    --
    -----------------------------------------------------------------------------

    module Data.Bits (
      -- * Type classes
      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
      ),
      -- * Extra functions
      bitDefault,
      testBitDefault,
      popCountDefault,
      toIntegralSized,
      oneBits,
      -- * Newtypes
      And(..), Ior(..), Xor(..), Iff(..)
     ) where

    import GHC.Base
    import GHC.Bits
    import GHC.Enum
    import GHC.Read
    import GHC.Show

    -- $setup
    -- >>> import Prelude
    -- >>> import Data.Word

    -- | A more concise version of @complement zeroBits@.
    --
    -- >>> complement (zeroBits :: Word) == (oneBits :: Word)
    -- True
    --
    -- >>> complement (oneBits :: Word) == (zeroBits :: Word)
    -- True
    --
    -- = Note
    --
    -- The constraint on 'oneBits' is arguably too strong. However, as some types
    -- (such as 'Natural') have undefined 'complement', this is the only safe
    -- choice.
    --
    -- @since 4.16
    oneBits :: (FiniteBits a) => a
    oneBits :: forall a. FiniteBits a => a
    oneBits = forall a. Bits a => a -> a
    complement forall a. Bits a => a
    zeroBits
    {-# INLINE oneBits #-}

    -- | Monoid under bitwise AND.
    --
    -- >>> getAnd (And 0xab <> And 0x12) :: Word8
    -- 2
    --
    -- @since 4.16
    newtype And a = And { forall a. And a -> a
    getAnd :: a }
      deriving newtype (
                        And a
    forall a. a -> a -> Bounded a
    forall a. Bounded a => And a
    maxBound :: And a
    $cmaxBound :: forall a. Bounded a => And a
    minBound :: And a
    $cminBound :: forall a. Bounded a => And a
    Bounded, -- ^ @since 4.16
                        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]
    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
    enumFromThenTo :: And a -> And a -> And a -> [And a]
    $cenumFromThenTo :: forall a. Enum a => And a -> And a -> And a -> [And a]
    enumFromTo :: And a -> And a -> [And a]
    $cenumFromTo :: forall a. Enum a => And a -> And a -> [And a]
    enumFromThen :: And a -> And a -> [And a]
    $cenumFromThen :: forall a. Enum a => And a -> And a -> [And a]
    enumFrom :: And a -> [And a]
    $cenumFrom :: forall a. Enum a => And a -> [And a]
    fromEnum :: And a -> Int
    $cfromEnum :: forall a. Enum a => And a -> Int
    toEnum :: Int -> And a
    $ctoEnum :: forall a. Enum a => Int -> And a
    pred :: And a -> And a
    $cpred :: forall a. Enum a => And a -> And a
    succ :: And a -> And a
    $csucc :: forall a. Enum a => And a -> And a
    Enum, -- ^ @since 4.16
                        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
    popCount :: And a -> Int
    $cpopCount :: forall a. Bits a => And a -> Int
    rotateR :: And a -> Int -> And a
    $crotateR :: forall a. Bits a => And a -> Int -> And a
    rotateL :: And a -> Int -> And a
    $crotateL :: forall a. Bits a => And a -> Int -> And a
    unsafeShiftR :: And a -> Int -> And a
    $cunsafeShiftR :: forall a. Bits a => And a -> Int -> And a
    shiftR :: And a -> Int -> And a
    $cshiftR :: forall a. Bits a => And a -> Int -> And a
    unsafeShiftL :: And a -> Int -> And a
    $cunsafeShiftL :: forall a. Bits a => And a -> Int -> And a
    shiftL :: And a -> Int -> And a
    $cshiftL :: forall a. Bits a => And a -> Int -> And a
    isSigned :: And a -> Bool
    $cisSigned :: forall a. Bits a => And a -> Bool
    bitSize :: And a -> Int
    $cbitSize :: forall a. Bits a => And a -> Int
    bitSizeMaybe :: And a -> Maybe Int
    $cbitSizeMaybe :: forall a. Bits a => And a -> Maybe Int
    testBit :: And a -> Int -> Bool
    $ctestBit :: forall a. Bits a => And a -> Int -> Bool
    complementBit :: And a -> Int -> And a
    $ccomplementBit :: forall a. Bits a => And a -> Int -> And a
    clearBit :: And a -> Int -> And a
    $cclearBit :: forall a. Bits a => And a -> Int -> And a
    setBit :: And a -> Int -> And a
    $csetBit :: forall a. Bits a => And a -> Int -> And a
    bit :: Int -> And a
    $cbit :: forall a. Bits a => Int -> And a
    zeroBits :: And a
    $czeroBits :: forall a. Bits a => And a
    rotate :: And a -> Int -> And a
    $crotate :: forall a. Bits a => And a -> Int -> And a
    shift :: And a -> Int -> And a
    $cshift :: forall a. Bits a => And a -> Int -> And a
    complement :: And a -> And a
    $ccomplement :: forall a. Bits a => And a -> And a
    xor :: And a -> And a -> And a
    $cxor :: 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
    $c.&. :: forall a. Bits a => And a -> And a -> And a
    Bits, -- ^ @since 4.16
                        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
    countTrailingZeros :: And a -> Int
    $ccountTrailingZeros :: forall a. FiniteBits a => And a -> Int
    countLeadingZeros :: And a -> Int
    $ccountLeadingZeros :: forall a. FiniteBits a => And a -> Int
    finiteBitSize :: And a -> Int
    $cfiniteBitSize :: forall a. FiniteBits a => And a -> Int
    FiniteBits, -- ^ @since 4.16
                        And a -> And a -> Bool
    forall a. Eq a => And a -> And a -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: And a -> And a -> Bool
    $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
    Eq -- ^ @since 4.16
                        )
      deriving stock (
                      Int -> And a -> ShowS
    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
    showList :: [And a] -> ShowS
    $cshowList :: forall a. Show a => [And a] -> ShowS
    show :: And a -> String
    $cshow :: forall a. Show a => And a -> String
    showsPrec :: Int -> And a -> ShowS
    $cshowsPrec :: forall a. Show a => Int -> And a -> ShowS
    Show, -- ^ @since 4.16
                      ReadPrec [And a]
    ReadPrec (And a)
    ReadS [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
    readListPrec :: ReadPrec [And a]
    $creadListPrec :: forall a. Read a => ReadPrec [And a]
    readPrec :: ReadPrec (And a)
    $creadPrec :: forall a. Read a => ReadPrec (And a)
    readList :: ReadS [And a]
    $creadList :: forall a. Read a => ReadS [And a]
    readsPrec :: Int -> ReadS (And a)
    $creadsPrec :: forall a. Read a => Int -> ReadS (And a)
    Read -- ^ @since 4.16
                     )

    -- | @since 4.16
    instance (Bits a) => Semigroup (And a) where
      And a
    x <> :: And a -> And a -> And a
    <> And a
    y = forall a. a -> And a
    And (a
    x forall a. Bits a => a -> a -> a
    .&. a
    y)

    -- | This constraint is arguably too strong. However,
    -- as some types (such as 'Natural') have undefined 'complement', this is the
    -- only safe choice.
    --
    -- @since 4.16
    instance (FiniteBits a) => Monoid (And a) where
      mempty :: And a
    mempty = forall a. a -> And a
    And forall a. FiniteBits a => a
    oneBits

    -- | Monoid under bitwise inclusive OR.
    --
    -- >>> getIor (Ior 0xab <> Ior 0x12) :: Word8
    -- 187
    --
    -- @since 4.16
    newtype Ior a = Ior { forall a. Ior a -> a
    getIor :: a }
      deriving newtype (
                        Ior a
    forall a. a -> a -> Bounded a
    forall a. Bounded a => Ior a
    maxBound :: Ior a
    $cmaxBound :: forall a. Bounded a => Ior a
    minBound :: Ior a
    $cminBound :: forall a. Bounded a => Ior a
    Bounded, -- ^ @since 4.16
                        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]
    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
    enumFromThenTo :: Ior a -> Ior a -> Ior a -> [Ior a]
    $cenumFromThenTo :: forall a. Enum a => Ior a -> Ior a -> Ior a -> [Ior a]
    enumFromTo :: Ior a -> Ior a -> [Ior a]
    $cenumFromTo :: forall a. Enum a => Ior a -> Ior a -> [Ior a]
    enumFromThen :: Ior a -> Ior a -> [Ior a]
    $cenumFromThen :: forall a. Enum a => Ior a -> Ior a -> [Ior a]
    enumFrom :: Ior a -> [Ior a]
    $cenumFrom :: forall a. Enum a => Ior a -> [Ior a]
    fromEnum :: Ior a -> Int
    $cfromEnum :: forall a. Enum a => Ior a -> Int
    toEnum :: Int -> Ior a
    $ctoEnum :: forall a. Enum a => Int -> Ior a
    pred :: Ior a -> Ior a
    $cpred :: forall a. Enum a => Ior a -> Ior a
    succ :: Ior a -> Ior a
    $csucc :: forall a. Enum a => Ior a -> Ior a
    Enum, -- ^ @since 4.16
                        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
    popCount :: Ior a -> Int
    $cpopCount :: forall a. Bits a => Ior a -> Int
    rotateR :: Ior a -> Int -> Ior a
    $crotateR :: forall a. Bits a => Ior a -> Int -> Ior a
    rotateL :: Ior a -> Int -> Ior a
    $crotateL :: forall a. Bits a => Ior a -> Int -> Ior a
    unsafeShiftR :: Ior a -> Int -> Ior a
    $cunsafeShiftR :: forall a. Bits a => Ior a -> Int -> Ior a
    shiftR :: Ior a -> Int -> Ior a
    $cshiftR :: forall a. Bits a => Ior a -> Int -> Ior a
    unsafeShiftL :: Ior a -> Int -> Ior a
    $cunsafeShiftL :: forall a. Bits a => Ior a -> Int -> Ior a
    shiftL :: Ior a -> Int -> Ior a
    $cshiftL :: forall a. Bits a => Ior a -> Int -> Ior a
    isSigned :: Ior a -> Bool
    $cisSigned :: forall a. Bits a => Ior a -> Bool
    bitSize :: Ior a -> Int
    $cbitSize :: forall a. Bits a => Ior a -> Int
    bitSizeMaybe :: Ior a -> Maybe Int
    $cbitSizeMaybe :: forall a. Bits a => Ior a -> Maybe Int
    testBit :: Ior a -> Int -> Bool
    $ctestBit :: forall a. Bits a => Ior a -> Int -> Bool
    complementBit :: Ior a -> Int -> Ior a
    $ccomplementBit :: forall a. Bits a => Ior a -> Int -> Ior a
    clearBit :: Ior a -> Int -> Ior a
    $cclearBit :: forall a. Bits a => Ior a -> Int -> Ior a
    setBit :: Ior a -> Int -> Ior a
    $csetBit :: forall a. Bits a => Ior a -> Int -> Ior a
    bit :: Int -> Ior a
    $cbit :: forall a. Bits a => Int -> Ior a
    zeroBits :: Ior a
    $czeroBits :: forall a. Bits a => Ior a
    rotate :: Ior a -> Int -> Ior a
    $crotate :: forall a. Bits a => Ior a -> Int -> Ior a
    shift :: Ior a -> Int -> Ior a
    $cshift :: forall a. Bits a => Ior a -> Int -> Ior a
    complement :: Ior a -> Ior a
    $ccomplement :: forall a. Bits a => Ior a -> Ior a
    xor :: Ior a -> Ior a -> Ior a
    $cxor :: 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
    $c.&. :: forall a. Bits a => Ior a -> Ior a -> Ior a
    Bits, -- ^ @since 4.16
                        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
    countTrailingZeros :: Ior a -> Int
    $ccountTrailingZeros :: forall a. FiniteBits a => Ior a -> Int
    countLeadingZeros :: Ior a -> Int
    $ccountLeadingZeros :: forall a. FiniteBits a => Ior a -> Int
    finiteBitSize :: Ior a -> Int
    $cfiniteBitSize :: forall a. FiniteBits a => Ior a -> Int
    FiniteBits, -- ^ @since 4.16
                        Ior a -> Ior a -> Bool
    forall a. Eq a => Ior a -> Ior a -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Ior a -> Ior a -> Bool
    $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
    Eq -- ^ @since 4.16
                        )
      deriving stock (
                      Int -> Ior a -> ShowS
    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
    showList :: [Ior a] -> ShowS
    $cshowList :: forall a. Show a => [Ior a] -> ShowS
    show :: Ior a -> String
    $cshow :: forall a. Show a => Ior a -> String
    showsPrec :: Int -> Ior a -> ShowS
    $cshowsPrec :: forall a. Show a => Int -> Ior a -> ShowS
    Show, -- ^ @since 4.16
                      ReadPrec [Ior a]
    ReadPrec (Ior a)
    ReadS [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
    readListPrec :: ReadPrec [Ior a]
    $creadListPrec :: forall a. Read a => ReadPrec [Ior a]
    readPrec :: ReadPrec (Ior a)
    $creadPrec :: forall a. Read a => ReadPrec (Ior a)
    readList :: ReadS [Ior a]
    $creadList :: forall a. Read a => ReadS [Ior a]
    readsPrec :: Int -> ReadS (Ior a)
    $creadsPrec :: forall a. Read a => Int -> ReadS (Ior a)
    Read -- ^ @since 4.16
                     )

    -- | @since 4.16
    instance (Bits a) => Semigroup (Ior a) where
      Ior a
    x <> :: Ior a -> Ior a -> Ior a
    <> Ior a
    y = forall a. a -> Ior a
    Ior (a
    x forall a. Bits a => a -> a -> a
    .|. a
    y)

    -- | @since 4.16
    instance (Bits a) => Monoid (Ior a) where
      mempty :: Ior a
    mempty = forall a. a -> Ior a
    Ior forall a. Bits a => a
    zeroBits

    -- | Monoid under bitwise XOR.
    --
    -- >>> getXor (Xor 0xab <> Xor 0x12) :: Word8
    -- 185
    --
    -- @since 4.16
    newtype Xor a = Xor { forall a. Xor a -> a
    getXor :: a }
      deriving newtype (
                        Xor a
    forall a. a -> a -> Bounded a
    forall a. Bounded a => Xor a
    maxBound :: Xor a
    $cmaxBound :: forall a. Bounded a => Xor a
    minBound :: Xor a
    $cminBound :: forall a. Bounded a => Xor a
    Bounded, -- ^ @since 4.16
                        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]
    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
    enumFromThenTo :: Xor a -> Xor a -> Xor a -> [Xor a]
    $cenumFromThenTo :: forall a. Enum a => Xor a -> Xor a -> Xor a -> [Xor a]
    enumFromTo :: Xor a -> Xor a -> [Xor a]
    $cenumFromTo :: forall a. Enum a => Xor a -> Xor a -> [Xor a]
    enumFromThen :: Xor a -> Xor a -> [Xor a]
    $cenumFromThen :: forall a. Enum a => Xor a -> Xor a -> [Xor a]
    enumFrom :: Xor a -> [Xor a]
    $cenumFrom :: forall a. Enum a => Xor a -> [Xor a]
    fromEnum :: Xor a -> Int
    $cfromEnum :: forall a. Enum a => Xor a -> Int
    toEnum :: Int -> Xor a
    $ctoEnum :: forall a. Enum a => Int -> Xor a
    pred :: Xor a -> Xor a
    $cpred :: forall a. Enum a => Xor a -> Xor a
    succ :: Xor a -> Xor a
    $csucc :: forall a. Enum a => Xor a -> Xor a
    Enum, -- ^ @since 4.16
                        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
    popCount :: Xor a -> Int
    $cpopCount :: forall a. Bits a => Xor a -> Int
    rotateR :: Xor a -> Int -> Xor a
    $crotateR :: forall a. Bits a => Xor a -> Int -> Xor a
    rotateL :: Xor a -> Int -> Xor a
    $crotateL :: forall a. Bits a => Xor a -> Int -> Xor a
    unsafeShiftR :: Xor a -> Int -> Xor a
    $cunsafeShiftR :: forall a. Bits a => Xor a -> Int -> Xor a
    shiftR :: Xor a -> Int -> Xor a
    $cshiftR :: forall a. Bits a => Xor a -> Int -> Xor a
    unsafeShiftL :: Xor a -> Int -> Xor a
    $cunsafeShiftL :: forall a. Bits a => Xor a -> Int -> Xor a
    shiftL :: Xor a -> Int -> Xor a
    $cshiftL :: forall a. Bits a => Xor a -> Int -> Xor a
    isSigned :: Xor a -> Bool
    $cisSigned :: forall a. Bits a => Xor a -> Bool
    bitSize :: Xor a -> Int
    $cbitSize :: forall a. Bits a => Xor a -> Int
    bitSizeMaybe :: Xor a -> Maybe Int
    $cbitSizeMaybe :: forall a. Bits a => Xor a -> Maybe Int
    testBit :: Xor a -> Int -> Bool
    $ctestBit :: forall a. Bits a => Xor a -> Int -> Bool
    complementBit :: Xor a -> Int -> Xor a
    $ccomplementBit :: forall a. Bits a => Xor a -> Int -> Xor a
    clearBit :: Xor a -> Int -> Xor a
    $cclearBit :: forall a. Bits a => Xor a -> Int -> Xor a
    setBit :: Xor a -> Int -> Xor a
    $csetBit :: forall a. Bits a => Xor a -> Int -> Xor a
    bit :: Int -> Xor a
    $cbit :: forall a. Bits a => Int -> Xor a
    zeroBits :: Xor a
    $czeroBits :: forall a. Bits a => Xor a
    rotate :: Xor a -> Int -> Xor a
    $crotate :: forall a. Bits a => Xor a -> Int -> Xor a
    shift :: Xor a -> Int -> Xor a
    $cshift :: forall a. Bits a => Xor a -> Int -> Xor a
    complement :: Xor a -> Xor a
    $ccomplement :: forall a. Bits a => Xor a -> Xor a
    xor :: Xor a -> Xor a -> Xor a
    $cxor :: 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
    $c.&. :: forall a. Bits a => Xor a -> Xor a -> Xor a
    Bits, -- ^ @since 4.16
                        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
    countTrailingZeros :: Xor a -> Int
    $ccountTrailingZeros :: forall a. FiniteBits a => Xor a -> Int
    countLeadingZeros :: Xor a -> Int
    $ccountLeadingZeros :: forall a. FiniteBits a => Xor a -> Int
    finiteBitSize :: Xor a -> Int
    $cfiniteBitSize :: forall a. FiniteBits a => Xor a -> Int
    FiniteBits, -- ^ @since 4.16
                        Xor a -> Xor a -> Bool
    forall a. Eq a => Xor a -> Xor a -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Xor a -> Xor a -> Bool
    $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
    Eq -- ^ @since 4.16
                        )
      deriving stock (
                      Int -> Xor a -> ShowS
    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
    showList :: [Xor a] -> ShowS
    $cshowList :: forall a. Show a => [Xor a] -> ShowS
    show :: Xor a -> String
    $cshow :: forall a. Show a => Xor a -> String
    showsPrec :: Int -> Xor a -> ShowS
    $cshowsPrec :: forall a. Show a => Int -> Xor a -> ShowS
    Show, -- ^ @since 4.16
                      ReadPrec [Xor a]
    ReadPrec (Xor a)
    ReadS [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
    readListPrec :: ReadPrec [Xor a]
    $creadListPrec :: forall a. Read a => ReadPrec [Xor a]
    readPrec :: ReadPrec (Xor a)
    $creadPrec :: forall a. Read a => ReadPrec (Xor a)
    readList :: ReadS [Xor a]
    $creadList :: forall a. Read a => ReadS [Xor a]
    readsPrec :: Int -> ReadS (Xor a)
    $creadsPrec :: forall a. Read a => Int -> ReadS (Xor a)
    Read -- ^ @since 4.16
                     )

    -- | @since 4.16
    instance (Bits a) => Semigroup (Xor a) where
      Xor a
    x <> :: Xor a -> Xor a -> Xor a
    <> Xor a
    y = forall a. a -> Xor a
    Xor (a
    x forall a. Bits a => a -> a -> a
    `xor` a
    y)

    -- | @since 4.16
    instance (Bits a) => Monoid (Xor a) where
      mempty :: Xor a
    mempty = forall a. a -> Xor a
    Xor forall a. Bits a => a
    zeroBits

    -- | Monoid under bitwise \'equality\'; defined as @1@ if the corresponding
    -- bits match, and @0@ otherwise.
    --
    -- >>> getIff (Iff 0xab <> Iff 0x12) :: Word8
    -- 70
    --
    -- @since 4.16
    newtype Iff a = Iff { forall a. Iff a -> a
    getIff :: a }
      deriving newtype (
                        Iff a
    forall a. a -> a -> Bounded a
    forall a. Bounded a => Iff a
    maxBound :: Iff a
    $cmaxBound :: forall a. Bounded a => Iff a
    minBound :: Iff a
    $cminBound :: forall a. Bounded a => Iff a
    Bounded, -- ^ @since 4.16
                        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]
    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
    enumFromThenTo :: Iff a -> Iff a -> Iff a -> [Iff a]
    $cenumFromThenTo :: forall a. Enum a => Iff a -> Iff a -> Iff a -> [Iff a]
    enumFromTo :: Iff a -> Iff a -> [Iff a]
    $cenumFromTo :: forall a. Enum a => Iff a -> Iff a -> [Iff a]
    enumFromThen :: Iff a -> Iff a -> [Iff a]
    $cenumFromThen :: forall a. Enum a => Iff a -> Iff a -> [Iff a]
    enumFrom :: Iff a -> [Iff a]
    $cenumFrom :: forall a. Enum a => Iff a -> [Iff a]
    fromEnum :: Iff a -> Int
    $cfromEnum :: forall a. Enum a => Iff a -> Int
    toEnum :: Int -> Iff a
    $ctoEnum :: forall a. Enum a => Int -> Iff a
    pred :: Iff a -> Iff a
    $cpred :: forall a. Enum a => Iff a -> Iff a
    succ :: Iff a -> Iff a
    $csucc :: forall a. Enum a => Iff a -> Iff a
    Enum, -- ^ @since 4.16
                        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
    popCount :: Iff a -> Int
    $cpopCount :: forall a. Bits a => Iff a -> Int
    rotateR :: Iff a -> Int -> Iff a
    $crotateR :: forall a. Bits a => Iff a -> Int -> Iff a
    rotateL :: Iff a -> Int -> Iff a
    $crotateL :: forall a. Bits a => Iff a -> Int -> Iff a
    unsafeShiftR :: Iff a -> Int -> Iff a
    $cunsafeShiftR :: forall a. Bits a => Iff a -> Int -> Iff a
    shiftR :: Iff a -> Int -> Iff a
    $cshiftR :: forall a. Bits a => Iff a -> Int -> Iff a
    unsafeShiftL :: Iff a -> Int -> Iff a
    $cunsafeShiftL :: forall a. Bits a => Iff a -> Int -> Iff a
    shiftL :: Iff a -> Int -> Iff a
    $cshiftL :: forall a. Bits a => Iff a -> Int -> Iff a
    isSigned :: Iff a -> Bool
    $cisSigned :: forall a. Bits a => Iff a -> Bool
    bitSize :: Iff a -> Int
    $cbitSize :: forall a. Bits a => Iff a -> Int
    bitSizeMaybe :: Iff a -> Maybe Int
    $cbitSizeMaybe :: forall a. Bits a => Iff a -> Maybe Int
    testBit :: Iff a -> Int -> Bool
    $ctestBit :: forall a. Bits a => Iff a -> Int -> Bool
    complementBit :: Iff a -> Int -> Iff a
    $ccomplementBit :: forall a. Bits a => Iff a -> Int -> Iff a
    clearBit :: Iff a -> Int -> Iff a
    $cclearBit :: forall a. Bits a => Iff a -> Int -> Iff a
    setBit :: Iff a -> Int -> Iff a
    $csetBit :: forall a. Bits a => Iff a -> Int -> Iff a
    bit :: Int -> Iff a
    $cbit :: forall a. Bits a => Int -> Iff a
    zeroBits :: Iff a
    $czeroBits :: forall a. Bits a => Iff a
    rotate :: Iff a -> Int -> Iff a
    $crotate :: forall a. Bits a => Iff a -> Int -> Iff a
    shift :: Iff a -> Int -> Iff a
    $cshift :: forall a. Bits a => Iff a -> Int -> Iff a
    complement :: Iff a -> Iff a
    $ccomplement :: forall a. Bits a => Iff a -> Iff a
    xor :: Iff a -> Iff a -> Iff a
    $cxor :: 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
    $c.&. :: forall a. Bits a => Iff a -> Iff a -> Iff a
    Bits, -- ^ @since 4.16
                        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
    countTrailingZeros :: Iff a -> Int
    $ccountTrailingZeros :: forall a. FiniteBits a => Iff a -> Int
    countLeadingZeros :: Iff a -> Int
    $ccountLeadingZeros :: forall a. FiniteBits a => Iff a -> Int
    finiteBitSize :: Iff a -> Int
    $cfiniteBitSize :: forall a. FiniteBits a => Iff a -> Int
    FiniteBits, -- ^ @since 4.16
                        Iff a -> Iff a -> Bool
    forall a. Eq a => Iff a -> Iff a -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Iff a -> Iff a -> Bool
    $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
    Eq -- ^ @since 4.16
                        )
      deriving stock (
                      Int -> Iff a -> ShowS
    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
    showList :: [Iff a] -> ShowS
    $cshowList :: forall a. Show a => [Iff a] -> ShowS
    show :: Iff a -> String
    $cshow :: forall a. Show a => Iff a -> String
    showsPrec :: Int -> Iff a -> ShowS
    $cshowsPrec :: forall a. Show a => Int -> Iff a -> ShowS
    Show, -- ^ @since 4.16
                      ReadPrec [Iff a]
    ReadPrec (Iff a)
    ReadS [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
    readListPrec :: ReadPrec [Iff a]
    $creadListPrec :: forall a. Read a => ReadPrec [Iff a]
    readPrec :: ReadPrec (Iff a)
    $creadPrec :: forall a. Read a => ReadPrec (Iff a)
    readList :: ReadS [Iff a]
    $creadList :: forall a. Read a => ReadS [Iff a]
    readsPrec :: Int -> ReadS (Iff a)
    $creadsPrec :: forall a. Read a => Int -> ReadS (Iff a)
    Read -- ^ @since 4.16
                     )

    -- | This constraint is arguably
    -- too strong. However, as some types (such as 'Natural') have undefined
    -- 'complement', this is the only safe choice.
    --
    -- @since 4.16
    instance (FiniteBits a) => Semigroup (Iff a) where
      Iff a
    x <> :: Iff a -> Iff a -> Iff a
    <> Iff a
    y = forall a. a -> Iff a
    Iff forall b c a. (b -> c) -> (a -> b) -> a -> c
    . forall a. Bits a => a -> a
    complement forall a b. (a -> b) -> a -> b
    $ (a
    x forall a. Bits a => a -> a -> a
    `xor` a
    y)

    -- | This constraint is arguably
    -- too strong. However, as some types (such as 'Natural') have undefined
    -- 'complement', this is the only safe choice.
    --
    -- @since 4.16
    instance (FiniteBits a) => Monoid (Iff a) where
      mempty :: Iff a
    mempty = forall a. a -> Iff a
    Iff forall a. FiniteBits a => a
    oneBits