module Data.BitArray.Immutable where
import Data.Word
import Data.Bits
import Data.Array.Unboxed
data BitArray = A
{ BitArray -> Int
_first :: {-# UNPACK #-} !Int
, BitArray -> Int
_last :: {-# UNPACK #-} !Int
, BitArray -> UArray Int Word64
_words :: {-# UNPACK #-} !(UArray Int Word64)
}
ind :: Int -> (Int,Int)
ind :: Int -> (Int, Int)
ind Int
i = (Int
k,Int
l) where
k :: Int
k = Int
i Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`shiftR` Int
6
l :: Int
l = Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
k Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`shiftL` Int
6
{-# SPECIALIZE intToBool :: Int -> Bool #-}
intToBool :: Integral a => a -> Bool
intToBool :: a -> Bool
intToBool a
n = case a
n of
a
0 -> Bool
False
a
_ -> Bool
True
{-# SPECIALIZE boolToInt :: Bool -> Int #-}
boolToInt :: Integral a => Bool -> a
boolToInt :: Bool -> a
boolToInt Bool
b = case Bool
b of
Bool
False -> a
0
Bool
True -> a
1