[Git][ghc/ghc][master] Implement (Functor.<$) for Array

Marge Bot gitlab at gitlab.haskell.org
Fri May 31 06:01:59 UTC 2019



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
0c6f7f7e by Simon Jakobi at 2019-05-31T06:01:55Z
Implement (Functor.<$) for Array

- - - - -


1 changed file:

- libraries/base/GHC/Arr.hs


Changes:

=====================================
libraries/base/GHC/Arr.hs
=====================================
@@ -848,6 +848,15 @@ cmpIntArray arr1@(Array l1 u1 n1 _) arr2@(Array l2 u2 n2 _) =
 instance Functor (Array i) where
     fmap = amap
 
+    {-# INLINE (<$) #-}
+    x <$ Array l u n@(I# n#) _ =
+        -- Sadly we can't just use 'newSTArray' (with 'unsafeFreezeSTArray')
+        -- since that would require proof that the indices of the original array
+        -- are instances of 'Ix'.
+        runST $ ST $ \s1# ->
+            case newArray# n# x s1# of
+                (# s2#, marr# #) -> done l u n marr# s2#
+
 -- | @since 2.01
 instance (Ix i, Eq e) => Eq (Array i e) where
     (==) = eqArray



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/0c6f7f7eb94f80d3ed74a382af8a3294d070e740

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/0c6f7f7eb94f80d3ed74a382af8a3294d070e740
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190531/26c15d11/attachment.html>


More information about the ghc-commits mailing list