summaryrefslogtreecommitdiff
path: root/haskell/Data/BA.hs
diff options
context:
space:
mode:
Diffstat (limited to 'haskell/Data/BA.hs')
-rw-r--r--haskell/Data/BA.hs17
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 #-}
3module Data.BA where
4
5import GHC.Exts
6import Control.Monad.Primitive
7import Data.Primitive.Types
8import Data.Primitive.ByteArray
9
10-- | WARNING: Unsafe to use this on packed C structs.
11writeAtByte :: (Prim a, PrimMonad m) => MutableByteArray (PrimState m) -> Int -> a -> m ()
12writeAtByte buf offset a = writeByteArray buf (div offset $ I# (sizeOf# a)) a
13{-# INLINE writeAtByte #-}
14
15readAtByte :: forall a m. (Prim a, PrimMonad m) => MutableByteArray (PrimState m) -> Int -> m a
16readAtByte buf offset = readByteArray buf (div offset $ I# (sizeOf# (undefined :: a)))
17{-# INLINE readAtByte #-}