{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
-- |
-- Module      : Graphics.Color.Algebra.Binary
-- Copyright   : (c) Alexey Kuleshevich 2018-2025
-- License     : BSD3
-- Maintainer  : Alexey Kuleshevich <lehins@yandex.ru>
-- Stability   : experimental
-- Portability : non-portable
--
module Graphics.Color.Algebra.Binary
  ( Bit
  , zero
  , one
  , toBool
  , fromBool
  , toNum
  , fromNum
  ) where

import Data.Bits
import qualified Data.Vector.Generic as V
import qualified Data.Vector.Generic.Mutable as M
import qualified Data.Vector.Unboxed as U
import Foreign.Storable
import Graphics.Color.Algebra.Elevator
import Prelude hiding (map)
import Data.Coerce

-- | Under the hood, binary pixels are backed by `Word8`, but can only take
-- values of @0@ or @1@. Use `zero`\/`one` to construct a bit and `on`\/`off` to
-- construct a binary pixel.
newtype Bit = Bit Word8 deriving (Eq Bit
Eq Bit =>
(Bit -> Bit -> Ordering)
-> (Bit -> Bit -> Bool)
-> (Bit -> Bit -> Bool)
-> (Bit -> Bit -> Bool)
-> (Bit -> Bit -> Bool)
-> (Bit -> Bit -> Bit)
-> (Bit -> Bit -> Bit)
-> Ord Bit
Bit -> Bit -> Bool
Bit -> Bit -> Ordering
Bit -> Bit -> Bit
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Bit -> Bit -> Ordering
compare :: Bit -> Bit -> Ordering
$c< :: Bit -> Bit -> Bool
< :: Bit -> Bit -> Bool
$c<= :: Bit -> Bit -> Bool
<= :: Bit -> Bit -> Bool
$c> :: Bit -> Bit -> Bool
> :: Bit -> Bit -> Bool
$c>= :: Bit -> Bit -> Bool
>= :: Bit -> Bit -> Bool
$cmax :: Bit -> Bit -> Bit
max :: Bit -> Bit -> Bit
$cmin :: Bit -> Bit -> Bit
min :: Bit -> Bit -> Bit
Ord, Bit -> Bit -> Bool
(Bit -> Bit -> Bool) -> (Bit -> Bit -> Bool) -> Eq Bit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Bit -> Bit -> Bool
== :: Bit -> Bit -> Bool
$c/= :: Bit -> Bit -> Bool
/= :: Bit -> Bit -> Bool
Eq, Ptr Bit -> IO Bit
Ptr Bit -> Int -> IO Bit
Ptr Bit -> Int -> Bit -> IO ()
Ptr Bit -> Bit -> IO ()
Bit -> Int
(Bit -> Int)
-> (Bit -> Int)
-> (Ptr Bit -> Int -> IO Bit)
-> (Ptr Bit -> Int -> Bit -> IO ())
-> (forall b. Ptr b -> Int -> IO Bit)
-> (forall b. Ptr b -> Int -> Bit -> IO ())
-> (Ptr Bit -> IO Bit)
-> (Ptr Bit -> Bit -> IO ())
-> Storable Bit
forall b. Ptr b -> Int -> IO Bit
forall b. Ptr b -> Int -> Bit -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: Bit -> Int
sizeOf :: Bit -> Int
$calignment :: Bit -> Int
alignment :: Bit -> Int
$cpeekElemOff :: Ptr Bit -> Int -> IO Bit
peekElemOff :: Ptr Bit -> Int -> IO Bit
$cpokeElemOff :: Ptr Bit -> Int -> Bit -> IO ()
pokeElemOff :: Ptr Bit -> Int -> Bit -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO Bit
peekByteOff :: forall b. Ptr b -> Int -> IO Bit
$cpokeByteOff :: forall b. Ptr b -> Int -> Bit -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> Bit -> IO ()
$cpeek :: Ptr Bit -> IO Bit
peek :: Ptr Bit -> IO Bit
$cpoke :: Ptr Bit -> Bit -> IO ()
poke :: Ptr Bit -> Bit -> IO ()
Storable)


instance Show Bit where
  show :: Bit -> String
show (Bit Word8
0) = String
"0"
  show Bit
_       = String
"1"

cf :: (Word8 -> Word8) -> Bit -> Bit
cf :: (Word8 -> Word8) -> Bit -> Bit
cf = (Word8 -> Word8) -> Bit -> Bit
forall a b. Coercible a b => a -> b
coerce

cf2 :: (Word8 -> Word8 -> Word8) -> Bit -> Bit -> Bit
cf2 :: (Word8 -> Word8 -> Word8) -> Bit -> Bit -> Bit
cf2 = (Word8 -> Word8 -> Word8) -> Bit -> Bit -> Bit
forall a b. Coercible a b => a -> b
coerce

instance Bits Bit where
  .&. :: Bit -> Bit -> Bit
(.&.) = (Word8 -> Word8 -> Word8) -> Bit -> Bit -> Bit
cf2 Word8 -> Word8 -> Word8
forall a. Bits a => a -> a -> a
(.&.)
  {-# INLINE (.&.) #-}
  .|. :: Bit -> Bit -> Bit
(.|.) = (Word8 -> Word8 -> Word8) -> Bit -> Bit -> Bit
cf2 Word8 -> Word8 -> Word8
forall a. Bits a => a -> a -> a
(.|.)
  {-# INLINE (.|.) #-}
  xor :: Bit -> Bit -> Bit
xor = (Word8 -> Word8 -> Word8) -> Bit -> Bit -> Bit
cf2 Word8 -> Word8 -> Word8
forall a. Bits a => a -> a -> a
xor
  {-# INLINE xor #-}
  complement :: Bit -> Bit
complement = (Word8 -> Word8) -> Bit -> Bit
cf Word8 -> Word8
forall a. Bits a => a -> a
complement
  {-# INLINE complement #-}
  shift :: Bit -> Int -> Bit
shift !Bit
b Int
0 = Bit
b
  shift  Bit
_ Int
_ = Word8 -> Bit
Bit Word8
0
  {-# INLINE shift #-}
  rotate :: Bit -> Int -> Bit
rotate !Bit
b Int
_ = Bit
b
  {-# INLINE rotate #-}
  zeroBits :: Bit
zeroBits = Bit
zero
  {-# INLINE zeroBits #-}
  bit :: Int -> Bit
bit Int
0 = Bit
one
  bit Int
_ = Bit
zero
  {-# INLINE bit #-}
  testBit :: Bit -> Int -> Bool
testBit (Bit Word8
b) Int
0 = Word8
b Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
/= Word8
0
  testBit Bit
_       Int
_ = Bool
False
  {-# INLINE testBit #-}
  bitSizeMaybe :: Bit -> Maybe Int
bitSizeMaybe Bit
_ = Int -> Maybe Int
forall a. a -> Maybe a
Just Int
1
  {-# INLINE bitSizeMaybe #-}
  bitSize :: Bit -> Int
bitSize Bit
_ = Int
1
  {-# INLINE bitSize #-}
  isSigned :: Bit -> Bool
isSigned Bit
_ = Bool
False
  {-# INLINE isSigned #-}
  popCount :: Bit -> Int
popCount (Bit Word8
0) = Int
0
  popCount Bit
_       = Int
1
  {-# INLINE popCount #-}


-- | Convert `Bit` to `Bool`
--
-- @since 0.1.0
toBool :: Bit -> Bool
toBool :: Bit -> Bool
toBool (Bit Word8
0) = Bool
False
toBool Bit
_       = Bool
True
{-# INLINE toBool #-}

-- | Convert `Bool` to `Bit`
--
-- @since 0.1.0
fromBool :: Bool -> Bit
fromBool :: Bool -> Bit
fromBool Bool
False = Bit
zero
fromBool Bool
True  = Bit
one
{-# INLINE fromBool #-}

-- | Convert a bit to a number.
--
-- @since 0.1.0
toNum :: Num a => Bit -> a
toNum :: forall a. Num a => Bit -> a
toNum (Bit Word8
0) = a
0
toNum Bit
_       = a
1
{-# INLINE toNum #-}

-- | Convert a number to a bit. Any non-zero number corresponds to @1@.
--
-- @since 0.1.0
fromNum :: (Eq a, Num a) => a -> Bit
fromNum :: forall a. (Eq a, Num a) => a -> Bit
fromNum a
0 = Bit
zero
fromNum a
_ = Bit
one
{-# INLINE fromNum #-}


zero :: Bit
zero :: Bit
zero = Word8 -> Bit
forall a b. Coercible a b => a -> b
coerce (Word8
0x00 :: Word8)
{-# INLINE zero #-}

one :: Bit
one :: Bit
one = Word8 -> Bit
forall a b. Coercible a b => a -> b
coerce (Word8
0xff :: Word8)
{-# INLINE one #-}


-- | Values: @0@ and @1@
instance Elevator Bit where
  minValue :: Bit
minValue = Word8 -> Bit
Bit Word8
0x00
  {-# INLINE minValue #-}
  maxValue :: Bit
maxValue = Word8 -> Bit
Bit Word8
0xff
  {-# INLINE maxValue #-}
  toShowS :: Bit -> ShowS
toShowS (Bit Word8
0) = (Char
'0'Char -> ShowS
forall a. a -> [a] -> [a]
:)
  toShowS Bit
_       = (Char
'1'Char -> ShowS
forall a. a -> [a] -> [a]
:)
  toWord8 :: Bit -> Word8
toWord8 = Bit -> Word8
forall a b. Coercible a b => a -> b
coerce
  {-# INLINE toWord8 #-}
  toWord16 :: Bit -> Word16
toWord16 (Bit Word8
0) = Word16
0
  toWord16 Bit
_       = Word16
forall a. Bounded a => a
maxBound
  {-# INLINE toWord16 #-}
  toWord32 :: Bit -> Word32
toWord32 (Bit Word8
0) = Word32
0
  toWord32 Bit
_       = Word32
forall a. Bounded a => a
maxBound
  {-# INLINE toWord32 #-}
  toWord64 :: Bit -> Word64
toWord64 (Bit Word8
0) = Word64
0
  toWord64 Bit
_       = Word64
forall a. Bounded a => a
maxBound
  {-# INLINE toWord64 #-}
  toFloat :: Bit -> Float
toFloat (Bit Word8
0) = Float
0
  toFloat Bit
_       = Float
1
  {-# INLINE toFloat #-}
  toRealFloat :: forall a. (Elevator a, RealFloat a) => Bit -> a
toRealFloat (Bit Word8
0) = a
0
  toRealFloat Bit
_       = a
1
  {-# INLINE toRealFloat #-}
  fromRealFloat :: forall a. (Elevator a, RealFloat a) => a -> Bit
fromRealFloat a
0 = Bit
zero
  fromRealFloat a
_ = Bit
one
  {-# INLINE fromRealFloat #-}
  // :: Bit -> Bit -> Bit
(//) = (Word8 -> Word8 -> Word8) -> Bit -> Bit -> Bit
cf2 Word8 -> Word8 -> Word8
forall a. Integral a => a -> a -> a
div
  {-# INLINE (//) #-}


instance Num Bit where
  + :: Bit -> Bit -> Bit
(+) = Bit -> Bit -> Bit
forall a. Bits a => a -> a -> a
(.|.)
  {-# INLINE (+) #-}
  -- 0 - 0 = 0
  -- 0 - 1 = 0
  -- 1 - 0 = 1
  -- 1 - 1 = 0
  (Bit Word8
0) - :: Bit -> Bit -> Bit
- (Bit Word8
0) = Bit
zero
  Bit
_       - (Bit Word8
0) = Bit
one
  Bit
_       - Bit
_       = Bit
zero
  {-# INLINE (-) #-}
  * :: Bit -> Bit -> Bit
(*) = Bit -> Bit -> Bit
forall a. Bits a => a -> a -> a
(.&.)
  {-# INLINE (*) #-}
  abs :: Bit -> Bit
abs         = Bit -> Bit
forall a. a -> a
id
  {-# INLINE abs #-}
  signum :: Bit -> Bit
signum      = Bit -> Bit
forall a. a -> a
id
  {-# INLINE signum #-}
  fromInteger :: Integer -> Bit
fromInteger Integer
0 = Bit
zero
  fromInteger Integer
_ = Bit
one
  {-# INLINE fromInteger #-}

-- | Unboxing of a `Bit`.
instance U.Unbox Bit

newtype instance U.MVector s Bit = MV_Bit (U.MVector s Word8)

instance M.MVector U.MVector Bit where
  basicLength :: forall s. MVector s Bit -> Int
basicLength (MV_Bit MVector s Word8
mvec) = MVector s Word8 -> Int
forall s. MVector s Word8 -> Int
forall (v :: * -> * -> *) a s. MVector v a => v s a -> Int
M.basicLength MVector s Word8
mvec
  {-# INLINE basicLength #-}
  basicUnsafeSlice :: forall s. Int -> Int -> MVector s Bit -> MVector s Bit
basicUnsafeSlice Int
idx Int
len (MV_Bit MVector s Word8
mvec) = MVector s Word8 -> MVector s Bit
forall s. MVector s Word8 -> MVector s Bit
MV_Bit (Int -> Int -> MVector s Word8 -> MVector s Word8
forall s. Int -> Int -> MVector s Word8 -> MVector s Word8
forall (v :: * -> * -> *) a s.
MVector v a =>
Int -> Int -> v s a -> v s a
M.basicUnsafeSlice Int
idx Int
len MVector s Word8
mvec)
  {-# INLINE basicUnsafeSlice #-}
  basicOverlaps :: forall s. MVector s Bit -> MVector s Bit -> Bool
basicOverlaps (MV_Bit MVector s Word8
mvec) (MV_Bit MVector s Word8
mvec') = MVector s Word8 -> MVector s Word8 -> Bool
forall s. MVector s Word8 -> MVector s Word8 -> Bool
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> v s a -> Bool
M.basicOverlaps MVector s Word8
mvec MVector s Word8
mvec'
  {-# INLINE basicOverlaps #-}
  basicUnsafeNew :: forall s. Int -> ST s (MVector s Bit)
basicUnsafeNew Int
len = MVector s Word8 -> MVector s Bit
forall s. MVector s Word8 -> MVector s Bit
MV_Bit (MVector s Word8 -> MVector s Bit)
-> ST s (MVector s Word8) -> ST s (MVector s Bit)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> ST s (MVector s Word8)
forall s. Int -> ST s (MVector s Word8)
forall (v :: * -> * -> *) a s. MVector v a => Int -> ST s (v s a)
M.basicUnsafeNew Int
len
  {-# INLINE basicUnsafeNew #-}
  basicUnsafeReplicate :: forall s. Int -> Bit -> ST s (MVector s Bit)
basicUnsafeReplicate Int
len (Bit Word8
w) = MVector s Word8 -> MVector s Bit
forall s. MVector s Word8 -> MVector s Bit
MV_Bit (MVector s Word8 -> MVector s Bit)
-> ST s (MVector s Word8) -> ST s (MVector s Bit)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Word8 -> ST s (MVector s Word8)
forall s. Int -> Word8 -> ST s (MVector s Word8)
forall (v :: * -> * -> *) a s.
MVector v a =>
Int -> a -> ST s (v s a)
M.basicUnsafeReplicate Int
len Word8
w
  {-# INLINE basicUnsafeReplicate #-}
  basicUnsafeRead :: forall s. MVector s Bit -> Int -> ST s Bit
basicUnsafeRead (MV_Bit MVector s Word8
mvec) Int
idx = Word8 -> Bit
Bit (Word8 -> Bit) -> ST s Word8 -> ST s Bit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MVector s Word8 -> Int -> ST s Word8
forall s. MVector s Word8 -> Int -> ST s Word8
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> Int -> ST s a
M.basicUnsafeRead MVector s Word8
mvec Int
idx
  {-# INLINE basicUnsafeRead #-}
  basicUnsafeWrite :: forall s. MVector s Bit -> Int -> Bit -> ST s ()
basicUnsafeWrite (MV_Bit MVector s Word8
mvec) Int
idx (Bit Word8
w) = MVector s Word8 -> Int -> Word8 -> ST s ()
forall s. MVector s Word8 -> Int -> Word8 -> ST s ()
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> Int -> a -> ST s ()
M.basicUnsafeWrite MVector s Word8
mvec Int
idx Word8
w
  {-# INLINE basicUnsafeWrite #-}
  basicClear :: forall s. MVector s Bit -> ST s ()
basicClear (MV_Bit MVector s Word8
mvec) = MVector s Word8 -> ST s ()
forall s. MVector s Word8 -> ST s ()
forall (v :: * -> * -> *) a s. MVector v a => v s a -> ST s ()
M.basicClear MVector s Word8
mvec
  {-# INLINE basicClear #-}
  basicSet :: forall s. MVector s Bit -> Bit -> ST s ()
basicSet (MV_Bit MVector s Word8
mvec) (Bit Word8
w) =  MVector s Word8 -> Word8 -> ST s ()
forall s. MVector s Word8 -> Word8 -> ST s ()
forall (v :: * -> * -> *) a s. MVector v a => v s a -> a -> ST s ()
M.basicSet MVector s Word8
mvec Word8
w
  {-# INLINE basicSet #-}
  basicUnsafeCopy :: forall s. MVector s Bit -> MVector s Bit -> ST s ()
basicUnsafeCopy (MV_Bit MVector s Word8
mvec) (MV_Bit MVector s Word8
mvec') = MVector s Word8 -> MVector s Word8 -> ST s ()
forall s. MVector s Word8 -> MVector s Word8 -> ST s ()
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> v s a -> ST s ()
M.basicUnsafeCopy MVector s Word8
mvec MVector s Word8
mvec'
  {-# INLINE basicUnsafeCopy #-}
  basicUnsafeMove :: forall s. MVector s Bit -> MVector s Bit -> ST s ()
basicUnsafeMove (MV_Bit MVector s Word8
mvec) (MV_Bit MVector s Word8
mvec') = MVector s Word8 -> MVector s Word8 -> ST s ()
forall s. MVector s Word8 -> MVector s Word8 -> ST s ()
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> v s a -> ST s ()
M.basicUnsafeMove MVector s Word8
mvec MVector s Word8
mvec'
  {-# INLINE basicUnsafeMove #-}
  basicUnsafeGrow :: forall s. MVector s Bit -> Int -> ST s (MVector s Bit)
basicUnsafeGrow (MV_Bit MVector s Word8
mvec) Int
len = MVector s Word8 -> MVector s Bit
forall s. MVector s Word8 -> MVector s Bit
MV_Bit (MVector s Word8 -> MVector s Bit)
-> ST s (MVector s Word8) -> ST s (MVector s Bit)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MVector s Word8 -> Int -> ST s (MVector s Word8)
forall s. MVector s Word8 -> Int -> ST s (MVector s Word8)
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> Int -> ST s (v s a)
M.basicUnsafeGrow MVector s Word8
mvec Int
len
  {-# INLINE basicUnsafeGrow #-}
#if MIN_VERSION_vector(0,11,0)
  basicInitialize :: forall s. MVector s Bit -> ST s ()
basicInitialize (MV_Bit MVector s Word8
mvec) = MVector s Word8 -> ST s ()
forall s. MVector s Word8 -> ST s ()
forall (v :: * -> * -> *) a s. MVector v a => v s a -> ST s ()
M.basicInitialize MVector s Word8
mvec
  {-# INLINE basicInitialize #-}
#endif


newtype instance U.Vector Bit = V_Bit (U.Vector Word8)

instance V.Vector U.Vector Bit where
  basicUnsafeFreeze :: forall s. Mutable Vector s Bit -> ST s (Vector Bit)
basicUnsafeFreeze (MV_Bit MVector s Word8
mvec) = Vector Word8 -> Vector Bit
V_Bit (Vector Word8 -> Vector Bit)
-> ST s (Vector Word8) -> ST s (Vector Bit)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mutable Vector s Word8 -> ST s (Vector Word8)
forall s. Mutable Vector s Word8 -> ST s (Vector Word8)
forall (v :: * -> *) a s. Vector v a => Mutable v s a -> ST s (v a)
V.basicUnsafeFreeze Mutable Vector s Word8
MVector s Word8
mvec
  {-# INLINE basicUnsafeFreeze #-}
  basicUnsafeThaw :: forall s. Vector Bit -> ST s (Mutable Vector s Bit)
basicUnsafeThaw (V_Bit Vector Word8
vec) = MVector s Word8 -> MVector s Bit
forall s. MVector s Word8 -> MVector s Bit
MV_Bit (MVector s Word8 -> MVector s Bit)
-> ST s (MVector s Word8) -> ST s (MVector s Bit)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Vector Word8 -> ST s (Mutable Vector s Word8)
forall s. Vector Word8 -> ST s (Mutable Vector s Word8)
forall (v :: * -> *) a s. Vector v a => v a -> ST s (Mutable v s a)
V.basicUnsafeThaw Vector Word8
vec
  {-# INLINE basicUnsafeThaw #-}
  basicLength :: Vector Bit -> Int
basicLength (V_Bit Vector Word8
vec) = Vector Word8 -> Int
forall (v :: * -> *) a. Vector v a => v a -> Int
V.basicLength Vector Word8
vec
  {-# INLINE basicLength #-}
  basicUnsafeSlice :: Int -> Int -> Vector Bit -> Vector Bit
basicUnsafeSlice Int
idx Int
len (V_Bit Vector Word8
vec) = Vector Word8 -> Vector Bit
V_Bit (Int -> Int -> Vector Word8 -> Vector Word8
forall (v :: * -> *) a. Vector v a => Int -> Int -> v a -> v a
V.basicUnsafeSlice Int
idx Int
len Vector Word8
vec)
  {-# INLINE basicUnsafeSlice #-}
  basicUnsafeIndexM :: Vector Bit -> Int -> Box Bit
basicUnsafeIndexM (V_Bit Vector Word8
vec) Int
idx = Word8 -> Bit
Bit (Word8 -> Bit) -> Box Word8 -> Box Bit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Vector Word8 -> Int -> Box Word8
forall (v :: * -> *) a. Vector v a => v a -> Int -> Box a
V.basicUnsafeIndexM Vector Word8
vec Int
idx
  {-# INLINE basicUnsafeIndexM #-}
  basicUnsafeCopy :: forall s. Mutable Vector s Bit -> Vector Bit -> ST s ()
basicUnsafeCopy (MV_Bit MVector s Word8
mvec) (V_Bit Vector Word8
vec) = Mutable Vector s Word8 -> Vector Word8 -> ST s ()
forall s. Mutable Vector s Word8 -> Vector Word8 -> ST s ()
forall (v :: * -> *) a s.
Vector v a =>
Mutable v s a -> v a -> ST s ()
V.basicUnsafeCopy Mutable Vector s Word8
MVector s Word8
mvec Vector Word8
vec
  {-# INLINE basicUnsafeCopy #-}
  elemseq :: forall b. Vector Bit -> Bit -> b -> b
elemseq (V_Bit Vector Word8
vec) (Bit Word8
w) = Vector Word8 -> Word8 -> b -> b
forall b. Vector Word8 -> Word8 -> b -> b
forall (v :: * -> *) a b. Vector v a => v a -> a -> b -> b
V.elemseq Vector Word8
vec Word8
w
  {-# INLINE elemseq #-}