[commit: packages/containers] changelog-foldtree, cleaned_bugfix394, master, merge-doc-target, merge-fixes-5.9, merge-restrict-fix-5.8, revert-184-generic, revert-408-bugfix_394: Add unnecessary call in fromArray to make (Ix i) constraint look needed. (6004065)

git at git.haskell.org git at git.haskell.org
Mon Apr 17 21:37:40 UTC 2017


Repository : ssh://git@git.haskell.org/containers

On branches: changelog-foldtree,cleaned_bugfix394,master,merge-doc-target,merge-fixes-5.9,merge-restrict-fix-5.8,revert-184-generic,revert-408-bugfix_394
Link       : http://git.haskell.org/packages/containers.git/commitdiff/6004065c646a578fee51c8b6a35fb20514579507

>---------------------------------------------------------------

commit 6004065c646a578fee51c8b6a35fb20514579507
Author: Milan Straka <fox at ucw.cz>
Date:   Sat Jan 10 14:25:35 2015 +0100

    Add unnecessary call in fromArray to make (Ix i) constraint look needed.


>---------------------------------------------------------------

6004065c646a578fee51c8b6a35fb20514579507
 Data/Sequence.hs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Data/Sequence.hs b/Data/Sequence.hs
index 21c54d3..b62b16a 100644
--- a/Data/Sequence.hs
+++ b/Data/Sequence.hs
@@ -186,6 +186,7 @@ import Data.Data
 
 -- Array stuff, with GHC.Arr on GHC
 import Data.Array (Ix, Array)
+import qualified Data.Array
 #ifdef __GLASGOW_HASKELL__
 import qualified GHC.Arr
 #endif
@@ -1649,6 +1650,10 @@ fromFunction len f | len < 0 = error "Data.Sequence.fromFunction called with neg
 fromArray :: Ix i => Array i a -> Seq a
 #ifdef __GLASGOW_HASKELL__
 fromArray a = fromFunction (GHC.Arr.numElements a) (GHC.Arr.unsafeAt a)
+ where
+  -- The following definition uses (Ix i) constraing, which is needed for the
+  -- other fromArray definition.
+  _ = Data.Array.rangeSize (Data.Array.bounds a)
 #else
 fromArray a = fromList2 (Data.Array.rangeSize (Data.Array.bounds a)) (Data.Array.elems a)
 #endif



More information about the ghc-commits mailing list