diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-10-28 23:01:32 -0400 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-10-28 23:01:32 -0400 |
commit | 9b02922914a90c7a0b5751ca5d4293e00caf366b (patch) | |
tree | 87376eb923b7c186942b9eb5ba796ca6b5b9214f | |
parent | ee58401f82494ea48216e77edf2d80b8741336c1 (diff) |
remove IsMultipleOf type foo to build on older ghc
-rw-r--r-- | haskell/Data/Primitive/ByteArray/Util.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/haskell/Data/Primitive/ByteArray/Util.hs b/haskell/Data/Primitive/ByteArray/Util.hs index de944e7..83a2e7d 100644 --- a/haskell/Data/Primitive/ByteArray/Util.hs +++ b/haskell/Data/Primitive/ByteArray/Util.hs | |||
@@ -7,6 +7,7 @@ | |||
7 | {-# LANGUAGE ScopedTypeVariables #-} | 7 | {-# LANGUAGE ScopedTypeVariables #-} |
8 | {-# LANGUAGE TypeFamilies #-} | 8 | {-# LANGUAGE TypeFamilies #-} |
9 | {-# LANGUAGE TypeOperators #-} | 9 | {-# LANGUAGE TypeOperators #-} |
10 | {-# LANGUAGE CPP #-} | ||
10 | module Data.Primitive.ByteArray.Util where | 11 | module Data.Primitive.ByteArray.Util where |
11 | 12 | ||
12 | import GHC.Exts (Ptr(..)) | 13 | import GHC.Exts (Ptr(..)) |
@@ -37,7 +38,9 @@ instance n ~ (q * k) => IsMultipleOf n k | |||
37 | 38 | ||
38 | writeAtByte :: ( Prim a | 39 | writeAtByte :: ( Prim a |
39 | , PrimMonad m | 40 | , PrimMonad m |
41 | #if __GLASGOW_HASKELL__ >= 802 | ||
40 | , IsMultipleOf n (SizeOf a) | 42 | , IsMultipleOf n (SizeOf a) |
43 | #endif | ||
41 | ) => MutableByteArray (PrimState m) -> Offset n -> a -> m () | 44 | ) => MutableByteArray (PrimState m) -> Offset n -> a -> m () |
42 | writeAtByte buf (Offset offset) a = writeByteArray buf (div offset $ (sizeOf a)) a | 45 | writeAtByte buf (Offset offset) a = writeByteArray buf (div offset $ (sizeOf a)) a |
43 | {-# INLINE writeAtByte #-} | 46 | {-# INLINE writeAtByte #-} |
@@ -45,7 +48,9 @@ writeAtByte buf (Offset offset) a = writeByteArray buf (div offset $ (sizeOf a)) | |||
45 | readAtByte :: forall a m n. | 48 | readAtByte :: forall a m n. |
46 | ( Prim a | 49 | ( Prim a |
47 | , PrimMonad m | 50 | , PrimMonad m |
51 | #if __GLASGOW_HASKELL__ >= 802 | ||
48 | , IsMultipleOf n (SizeOf a) | 52 | , IsMultipleOf n (SizeOf a) |
53 | #endif | ||
49 | ) => MutableByteArray (PrimState m) -> Offset n -> m a | 54 | ) => MutableByteArray (PrimState m) -> Offset n -> m a |
50 | readAtByte buf (Offset offset) = readByteArray buf (div offset $ (sizeOf (undefined :: a))) | 55 | readAtByte buf (Offset offset) = readByteArray buf (div offset $ (sizeOf (undefined :: a))) |
51 | {-# INLINE readAtByte #-} | 56 | {-# INLINE readAtByte #-} |