[Git][ghc/ghc][wip/tsan/fixes] 4 commits: Add `Data.Functor.unzip`
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Thu Mar 9 15:18:57 UTC 2023
Ben Gamari pushed to branch wip/tsan/fixes at Glasgow Haskell Compiler / GHC
Commits:
fa559c28 by Ollie Charles at 2023-03-07T20:56:21+00:00
Add `Data.Functor.unzip`
This function is currently present in `Data.List.NonEmpty`, but `Data.Functor`
is a better home for it. This change was discussed and approved by the CLC
at https://github.com/haskell/core-libraries-committee/issues/88.
- - - - -
2aa07708 by MorrowM at 2023-03-07T21:22:22-05:00
Fix documentation for traceWith and friends
- - - - -
3dfa454c by Ben Gamari at 2023-03-08T16:58:59-05:00
compiler: Style fixes
- - - - -
c4a11baf by Ben Gamari at 2023-03-09T10:08:40-05:00
Merge remote-tracking branch 'origin/wip/tsan/fixes' into wip/tsan/fixes
- - - - -
4 changed files:
- compiler/GHC/Cmm/ThreadSanitizer.hs
- libraries/base/Data/Functor.hs
- libraries/base/Debug/Trace.hs
- libraries/base/changelog.md
Changes:
=====================================
compiler/GHC/Cmm/ThreadSanitizer.hs
=====================================
@@ -37,11 +37,11 @@ mapBlockList :: (forall e' x'. n e' x' -> Block n e' x')
mapBlockList f (BlockCO n rest ) = f n `blockAppend` mapBlockList f rest
mapBlockList f (BlockCC n rest m) = f n `blockAppend` mapBlockList f rest `blockAppend` f m
mapBlockList f (BlockOC rest m) = mapBlockList f rest `blockAppend` f m
-mapBlockList _ BNil = BNil
-mapBlockList f (BMiddle blk) = f blk
-mapBlockList f (BCat a b) = mapBlockList f a `blockAppend` mapBlockList f b
-mapBlockList f (BSnoc a n) = mapBlockList f a `blockAppend` f n
-mapBlockList f (BCons n a) = f n `blockAppend` mapBlockList f a
+mapBlockList _ BNil = BNil
+mapBlockList f (BMiddle blk) = f blk
+mapBlockList f (BCat a b) = mapBlockList f a `blockAppend` mapBlockList f b
+mapBlockList f (BSnoc a n) = mapBlockList f a `blockAppend` f n
+mapBlockList f (BCons n a) = f n `blockAppend` mapBlockList f a
annotateBlock :: Env -> Block CmmNode e x -> Block CmmNode e x
annotateBlock env = mapBlockList (annotateNode env)
@@ -112,10 +112,10 @@ annotatePrim :: Env
-> [CmmActual] -- ^ arguments
-> Maybe (Block CmmNode O O)
-- ^ 'Just' a block of instrumentation, if applicable
-annotatePrim env (MO_AtomicRMW w aop) [dest] [addr, val] = Just $ tsanAtomicRMW env MemOrderSeqCst aop w addr val dest
-annotatePrim env (MO_AtomicRead w mord) [dest] [addr] = Just $ tsanAtomicLoad env mord w addr dest
-annotatePrim env (MO_AtomicWrite w mord) [] [addr, val] = Just $ tsanAtomicStore env mord w val addr
-annotatePrim env (MO_Xchg w) [dest] [addr, val] = Just $ tsanAtomicExchange env MemOrderSeqCst w val addr dest
+annotatePrim env (MO_AtomicRMW w aop) [dest] [addr, val] = Just $ tsanAtomicRMW env MemOrderSeqCst aop w addr val dest
+annotatePrim env (MO_AtomicRead w mord) [dest] [addr] = Just $ tsanAtomicLoad env mord w addr dest
+annotatePrim env (MO_AtomicWrite w mord) [] [addr, val] = Just $ tsanAtomicStore env mord w val addr
+annotatePrim env (MO_Xchg w) [dest] [addr, val] = Just $ tsanAtomicExchange env MemOrderSeqCst w val addr dest
annotatePrim env (MO_Cmpxchg w) [dest] [addr, expected, new]
= Just $ tsanAtomicCas env MemOrderSeqCst MemOrderSeqCst w addr expected new dest
annotatePrim _ _ _ _ = Nothing
=====================================
libraries/base/Data/Functor.hs
=====================================
@@ -43,10 +43,12 @@ module Data.Functor
($>),
(<$>),
(<&>),
+ unzip,
void,
) where
import GHC.Base ( Functor(..), flip )
+import Data.Tuple ( fst, snd )
-- $setup
-- Allow the use of Prelude in doctests.
@@ -159,6 +161,9 @@ infixl 4 $>
($>) :: Functor f => f a -> b -> f b
($>) = flip (<$)
+unzip :: Functor f => f (a,b) -> (f a, f b)
+unzip xs = (fst <$> xs, snd <$> xs)
+
-- | @'void' value@ discards or ignores the result of evaluation, such
-- as the return value of an 'System.IO.IO' action.
--
=====================================
libraries/base/Debug/Trace.hs
=====================================
@@ -173,7 +173,7 @@ Like 'trace', but outputs the result of calling a function on the argument.
hello
("hello","world")
- at since 4.17.0.0
+ at since 4.18.0.0
-}
traceWith :: (a -> String) -> a -> a
traceWith f a = trace (f a) a
@@ -186,7 +186,7 @@ a 'String'.
3
[1,2,3]
- at since 4.17.0.0
+ at since 4.18.0.0
-}
traceShowWith :: Show b => (a -> b) -> a -> a
traceShowWith f = traceWith (show . f)
@@ -303,7 +303,7 @@ traceEventIO msg =
-- | Like 'traceEvent', but emits the result of calling a function on its
-- argument.
--
--- @since 4.17.0.0
+-- @since 4.18.0.0
traceEventWith :: (a -> String) -> a -> a
traceEventWith f a = traceEvent (f a) a
=====================================
libraries/base/changelog.md
=====================================
@@ -11,6 +11,7 @@
([CLC proposal #113](https://github.com/haskell/core-libraries-committee/issues/113))
* Add `Type.Reflection.decTypeRep`, `Data.Typeable.decT` and `Data.Typeable.hdecT` equality decisions functions.
([CLC proposal #98](https://github.com/haskell/core-libraries-committee/issues/98))
+ * Add `Data.Functor.unzip` ([CLC proposal #88](https://github.com/haskell/core-libraries-committee/issues/88))
## 4.18.0.0 *TBA*
@@ -82,6 +83,9 @@
* `InfoProv` now has additional `ipSrcFile` and `ipSrcSpan` fields. `ipLoc`
is now a function computed from these fields.
* The `whereFrom` function has been moved
+ * Add functions `traceWith`, `traceShowWith`, `traceEventWith` to
+ `Debug.Trace`, per
+ [CLC proposal #36](https://github.com/haskell/core-libraries-committee/issues/36).
## 4.17.0.0 *August 2022*
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/26cd9a595d8a393315a1c896d8956ee63dadce26...c4a11baffa2f1d02748ddaa00e49bbd7e40d5441
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/26cd9a595d8a393315a1c896d8956ee63dadce26...c4a11baffa2f1d02748ddaa00e49bbd7e40d5441
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/20230309/f416f000/attachment-0001.html>
More information about the ghc-commits
mailing list