diff options
Diffstat (limited to 'haskell/Data/BA.hs')
-rw-r--r-- | haskell/Data/BA.hs | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/haskell/Data/BA.hs b/haskell/Data/BA.hs deleted file mode 100644 index 60b1136..0000000 --- a/haskell/Data/BA.hs +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | {-# LANGUAGE MagicHash #-} | ||
2 | {-# LANGUAGE ScopedTypeVariables #-} | ||
3 | module Data.BA where | ||
4 | |||
5 | import GHC.Exts | ||
6 | import Control.Monad.Primitive | ||
7 | import Data.Primitive.Types | ||
8 | import Data.Primitive.ByteArray | ||
9 | |||
10 | -- | WARNING: Unsafe to use this on packed C structs. | ||
11 | writeAtByte :: (Prim a, PrimMonad m) => MutableByteArray (PrimState m) -> Int -> a -> m () | ||
12 | writeAtByte buf offset a = writeByteArray buf (div offset $ I# (sizeOf# a)) a | ||
13 | {-# INLINE writeAtByte #-} | ||
14 | |||
15 | readAtByte :: forall a m. (Prim a, PrimMonad m) => MutableByteArray (PrimState m) -> Int -> m a | ||
16 | readAtByte buf offset = readByteArray buf (div offset $ I# (sizeOf# (undefined :: a))) | ||
17 | {-# INLINE readAtByte #-} | ||