{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wno-dodgy-exports #-}
module Agda.Utils.IArray (module Agda.Utils.IArray, module Data.Array.IArray) where
import Data.Array.IArray
import Data.Array.Base ( IArray(..) )
import Data.Ix ( inRange )
#if MIN_VERSION_base(4,14,0)
import GHC.Ix ( unsafeIndex )
#endif
#if !MIN_VERSION_array(0,5,6)
{-# INLINE (!?) #-}
(!?) :: (IArray a e, Ix i) => a i e -> i -> Maybe e
(!?) arr i
| inRange b i = Just $ unsafeAt arr $
#if MIN_VERSION_base(4,14,0)
unsafeIndex b i
#else
index b i
#endif
| otherwise = Nothing
where b = bounds arr
#endif