Eliminate orphan rules and instances in the array package
[ghc-base.git] / Data / Traversable.hs
index 7ad3991..df10679 100644 (file)
@@ -43,6 +43,12 @@ import Control.Applicative
 import Data.Foldable (Foldable())
 import Data.Monoid (Monoid)
 
+#if defined(__GLASGOW_HASKELL__)
+import GHC.Arr
+#elif defined(__HUGS__)
+import Hugs.Array
+#endif
+
 -- | Functors representing data structures that can be traversed from
 -- left to right.
 --
@@ -104,6 +110,11 @@ instance Traversable [] where
 
         mapM = Prelude.mapM
 
+#ifndef __NHC__
+instance Ix i => Traversable (Array i) where
+    traverse f arr = listArray (bounds arr) `fmap` traverse f (elems arr)
+#endif
+
 -- general functions
 
 -- | 'for' is 'traverse' with its arguments flipped.