Skip to content
Snippets Groups Projects
Commit 592e8d18 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Move Foldable and Traversable instances for Array to Data.Array

parent 0a9e596c
No related tags found
No related merge requests found
{-# OPTIONS_GHC -fno-implicit-prelude #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | -- |
-- Module : Data.Array -- Module : Data.Array
...@@ -58,7 +57,7 @@ module Data.Array ...@@ -58,7 +57,7 @@ module Data.Array
import Data.Ix import Data.Ix
#ifdef __GLASGOW_HASKELL__ #ifdef __GLASGOW_HASKELL__
import GHC.Arr -- Most of the hard work is done here import GHC.Arr -- Most of the hard work is done here
import Data.Generics.Basics -- To provide a Data instance import Data.Generics.Basics -- To provide a Data instance
import Data.Generics.Instances -- To provide a Data instance import Data.Generics.Instances -- To provide a Data instance
import GHC.Err ( error ) -- Needed for Data instance import GHC.Err ( error ) -- Needed for Data instance
...@@ -72,7 +71,10 @@ import Hugs.Array ...@@ -72,7 +71,10 @@ import Hugs.Array
import Array -- Haskell'98 arrays import Array -- Haskell'98 arrays
#endif #endif
import Control.Applicative
import Data.Foldable
import Data.Typeable import Data.Typeable
import Data.Traversable
{- $intro {- $intro
Haskell provides indexable /arrays/, which may be thought of as functions Haskell provides indexable /arrays/, which may be thought of as functions
...@@ -86,3 +88,10 @@ Since most array functions involve the class 'Ix', this module is exported ...@@ -86,3 +88,10 @@ Since most array functions involve the class 'Ix', this module is exported
from "Data.Array" so that modules need not import both "Data.Array" and from "Data.Array" so that modules need not import both "Data.Array" and
"Data.Ix". "Data.Ix".
-} -}
instance Ix i => Foldable (Array i) where
foldr f z = Prelude.foldr f z . elems
instance Ix i => Traversable (Array i) where
traverse f arr = listArray (bounds arr) <$> traverse f (elems arr)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment