summaryrefslogtreecommitdiff
path: root/tests/examples/Base.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/examples/Base.hs')
-rw-r--r--tests/examples/Base.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/examples/Base.hs b/tests/examples/Base.hs
new file mode 100644
index 0000000..9fd44f4
--- /dev/null
+++ b/tests/examples/Base.hs
@@ -0,0 +1,26 @@
+{-# LANGUAGE BangPatterns, CPP, RankNTypes, MagicHash, UnboxedTuples, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, DeriveDataTypeable, UnliftedFFITypes #-}
+#if __GLASGOW_HASKELL__ >= 708
+{-# LANGUAGE RoleAnnotations #-}
+#endif
+{-# OPTIONS_HADDOCK hide #-}
+
+-- Flat unboxed arrays: instances
+
+instance IArray UArray Bool where
+ {-# INLINE bounds #-}
+ bounds (UArray l u _ _) = (l,u)
+ {-# INLINE numElements #-}
+ numElements (UArray _ _ n _) = n
+ {-# INLINE unsafeArray #-}
+ unsafeArray lu ies = runST (unsafeArrayUArray lu ies False)
+ {-# INLINE unsafeAt #-}
+ unsafeAt (UArray _ _ _ arr#) (I# i#) =
+ ((indexWordArray# arr# (bOOL_INDEX i#) `and#` bOOL_BIT i#)
+ `neWord#` int2Word# 0#)
+
+ {-# INLINE unsafeReplace #-}
+ unsafeReplace arr ies = runST (unsafeReplaceUArray arr ies)
+ {-# INLINE unsafeAccum #-}
+ unsafeAccum f arr ies = runST (unsafeAccumUArray f arr ies)
+ {-# INLINE unsafeAccumArray #-}
+ unsafeAccumArray f initialValue lu ies = runST (unsafeAccumArrayUArray f initialValue lu ies)