{-# language BangPatterns #-}
{-# language DataKinds #-}
{-# language MagicHash #-}
{-# language UnboxedTuples #-}
module Basics.Word8
(
T
, T#
, R
, lift
, unlift
, minus#
, quot#
, rem#
, gt#
, lt#
, gte#
, lte#
, eq#
, neq#
, gt
, lt
, gte
, lte
, eq
, neq
, read#
, write#
, index#
, set#
, uninitialized#
, initialized#
, uninitialized
, initialized
, copy#
, copyMutable#
, shrink#
, zero
, def
, maxBound
, minBound
, signed
, size
, shows
) where
import Prelude hiding (shows,minBound,maxBound)
import Data.Primitive (MutableByteArray(..))
import GHC.Exts hiding (setByteArray#)
import GHC.ST (ST(ST))
import GHC.Word
import qualified Prelude
import qualified GHC.Exts as Exts
type T = Word8
type T# = Word#
type R = 'WordRep
def :: T
{-# inline def #-}
def :: T
def = T
0
zero :: T
{-# inline zero #-}
zero :: T
zero = T
0
signed :: Bool
{-# inline signed #-}
signed :: Bool
signed = Bool
False
size :: Int
{-# inline size #-}
size :: Int
size = Int
1
maxBound :: T
{-# inline maxBound #-}
maxBound :: T
maxBound = T
255
minBound :: T
{-# inline minBound #-}
minBound :: T
minBound = T
0
lift :: T# -> T
{-# inline lift #-}
lift :: T# -> T
lift T#
i = Word8# -> T
W8# (T# -> Word8#
Exts.wordToWord8# T#
i)
unlift :: T -> T#
{-# inline unlift #-}
unlift :: T -> T#
unlift (W8# Word8#
i) = Word8# -> T#
Exts.word8ToWord# Word8#
i
gt# :: T# -> T# -> Int#
{-# inline gt# #-}
gt# :: T# -> T# -> Int#
gt# = T# -> T# -> Int#
gtWord#
lt# :: T# -> T# -> Int#
{-# inline lt# #-}
lt# :: T# -> T# -> Int#
lt# = T# -> T# -> Int#
ltWord#
gte# :: T# -> T# -> Int#
{-# inline gte# #-}
gte# :: T# -> T# -> Int#
gte# = T# -> T# -> Int#
geWord#
lte# :: T# -> T# -> Int#
{-# inline lte# #-}
lte# :: T# -> T# -> Int#
lte# = T# -> T# -> Int#
leWord#
eq# :: T# -> T# -> Int#
{-# inline eq# #-}
eq# :: T# -> T# -> Int#
eq# = T# -> T# -> Int#
eqWord#
neq# :: T# -> T# -> Int#
{-# inline neq# #-}
neq# :: T# -> T# -> Int#
neq# = T# -> T# -> Int#
neWord#
gt :: T -> T -> Bool
{-# inline gt #-}
gt :: T -> T -> Bool
gt = forall a. Ord a => a -> a -> Bool
(>)
lt :: T -> T -> Bool
{-# inline lt #-}
lt :: T -> T -> Bool
lt = forall a. Ord a => a -> a -> Bool
(<)
gte :: T -> T -> Bool
{-# inline gte #-}
gte :: T -> T -> Bool
gte = forall a. Ord a => a -> a -> Bool
(>=)
lte :: T -> T -> Bool
{-# inline lte #-}
lte :: T -> T -> Bool
lte = forall a. Ord a => a -> a -> Bool
(<=)
eq :: T -> T -> Bool
{-# inline eq #-}
eq :: T -> T -> Bool
eq = forall a. Eq a => a -> a -> Bool
(==)
neq :: T -> T -> Bool
{-# inline neq #-}
neq :: T -> T -> Bool
neq = forall a. Eq a => a -> a -> Bool
(/=)
minus# :: T# -> T# -> T#
{-# inline minus# #-}
minus# :: T# -> T# -> T#
minus# T#
x T#
y = T# -> T#
narrow8Word# (T# -> T# -> T#
minusWord# T#
x T#
y)
quot# :: T# -> T# -> T#
{-# inline quot# #-}
quot# :: T# -> T# -> T#
quot# = T# -> T# -> T#
quotWord#
rem# :: T# -> T# -> T#
{-# inline rem# #-}
rem# :: T# -> T# -> T#
rem# = T# -> T# -> T#
remWord#
index# :: ByteArray# -> Int# -> T#
{-# inline index# #-}
index# :: ByteArray# -> Int# -> T#
index# ByteArray#
arr Int#
i = Word8# -> T#
Exts.word8ToWord# (ByteArray# -> Int# -> Word8#
indexWord8Array# ByteArray#
arr Int#
i)
read# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, T# #)
{-# inline read# #-}
read# :: forall s.
MutableByteArray# s -> Int# -> State# s -> (# State# s, T# #)
read# MutableByteArray# s
arr Int#
i State# s
st =
let !(# State# s
st', Word8#
v #) = forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8# #)
readWord8Array# MutableByteArray# s
arr Int#
i State# s
st
in (# State# s
st', Word8# -> T#
Exts.word8ToWord# Word8#
v #)
write# :: MutableByteArray# s -> Int# -> T# -> State# s -> State# s
{-# inline write# #-}
write# :: forall s. MutableByteArray# s -> Int# -> T# -> State# s -> State# s
write# MutableByteArray# s
arr Int#
i T#
v State# s
st = forall d.
MutableByteArray# d -> Int# -> Word8# -> State# d -> State# d
writeWord8Array# MutableByteArray# s
arr Int#
i (T# -> Word8#
Exts.wordToWord8# T#
v) State# s
st
set# :: MutableByteArray# s -> Int# -> Int# -> T# -> State# s -> State# s
{-# inline set# #-}
set# :: forall s.
MutableByteArray# s -> Int# -> Int# -> T# -> State# s -> State# s
set# MutableByteArray# s
marr Int#
off Int#
len T#
x State# s
s = forall d.
MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d
Exts.setByteArray# MutableByteArray# s
marr Int#
off Int#
len (T# -> Int#
word2Int# T#
x) State# s
s
shrink# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
{-# inline shrink# #-}
shrink# :: forall s.
MutableByteArray# s
-> Int# -> State# s -> (# State# s, MutableByteArray# s #)
shrink# MutableByteArray# s
m Int#
i State# s
s = (# forall d. MutableByteArray# d -> Int# -> State# d -> State# d
Exts.shrinkMutableByteArray# MutableByteArray# s
m Int#
i State# s
s, MutableByteArray# s
m #)
uninitialized# :: Int# -> State# s -> (# State# s, MutableByteArray# s #)
{-# inline uninitialized# #-}
uninitialized# :: forall s. Int# -> State# s -> (# State# s, MutableByteArray# s #)
uninitialized# = forall s. Int# -> State# s -> (# State# s, MutableByteArray# s #)
Exts.newByteArray#
initialized# :: Int# -> T# -> State# s -> (# State# s, MutableByteArray# s #)
{-# inline initialized# #-}
initialized# :: forall s.
Int# -> T# -> State# s -> (# State# s, MutableByteArray# s #)
initialized# Int#
n T#
e State# s
s0 = case forall s. Int# -> State# s -> (# State# s, MutableByteArray# s #)
Exts.newByteArray# Int#
n State# s
s0 of
(# State# s
s1, MutableByteArray# s
a #) -> case forall s.
MutableByteArray# s -> Int# -> Int# -> T# -> State# s -> State# s
set# MutableByteArray# s
a Int#
0# Int#
n T#
e State# s
s1 of
State# s
s2 -> (# State# s
s2, MutableByteArray# s
a #)
uninitialized :: Int -> ST s (MutableByteArray s)
{-# inline uninitialized #-}
uninitialized :: forall s. Int -> ST s (MutableByteArray s)
uninitialized (I# Int#
sz) = forall s a. STRep s a -> ST s a
ST forall a b. (a -> b) -> a -> b
$ \State# s
s0 -> case forall s. Int# -> State# s -> (# State# s, MutableByteArray# s #)
uninitialized# Int#
sz State# s
s0 of
(# State# s
s1, MutableByteArray# s
a #) -> (# State# s
s1, forall s. MutableByteArray# s -> MutableByteArray s
MutableByteArray MutableByteArray# s
a #)
initialized :: Int -> T -> ST s (MutableByteArray s)
{-# inline initialized #-}
initialized :: forall s. Int -> T -> ST s (MutableByteArray s)
initialized (I# Int#
sz) T
e = forall s a. STRep s a -> ST s a
ST forall a b. (a -> b) -> a -> b
$ \State# s
s0 -> case forall s.
Int# -> T# -> State# s -> (# State# s, MutableByteArray# s #)
initialized# Int#
sz (T -> T#
unlift T
e) State# s
s0 of
(# State# s
s1, MutableByteArray# s
a #) -> (# State# s
s1, forall s. MutableByteArray# s -> MutableByteArray s
MutableByteArray MutableByteArray# s
a #)
copy# :: MutableByteArray# s -> Int# -> ByteArray# -> Int# -> Int# -> State# s -> State# s
{-# inline copy# #-}
copy# :: forall s.
MutableByteArray# s
-> Int# -> ByteArray# -> Int# -> Int# -> State# s -> State# s
copy# MutableByteArray# s
dst Int#
doff ByteArray#
src Int#
soff Int#
len =
forall d.
ByteArray#
-> Int#
-> MutableByteArray# d
-> Int#
-> Int#
-> State# d
-> State# d
Exts.copyByteArray# ByteArray#
src Int#
soff MutableByteArray# s
dst Int#
doff Int#
len
copyMutable# :: MutableByteArray# s -> Int# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
{-# inline copyMutable# #-}
copyMutable# :: forall s.
MutableByteArray# s
-> Int#
-> MutableByteArray# s
-> Int#
-> Int#
-> State# s
-> State# s
copyMutable# MutableByteArray# s
dst Int#
doff MutableByteArray# s
src Int#
soff Int#
len =
forall s.
MutableByteArray# s
-> Int#
-> MutableByteArray# s
-> Int#
-> Int#
-> State# s
-> State# s
Exts.copyMutableByteArray# MutableByteArray# s
src Int#
soff MutableByteArray# s
dst Int#
doff Int#
len
shows :: T -> String -> String
{-# inline shows #-}
shows :: T -> String -> String
shows = forall a. Show a => a -> String -> String
Prelude.shows