[commit: ghc] master: minor improvement to wording of warning against First. Add warning against Last (cf35ab9)
git at git.haskell.org
git at git.haskell.org
Thu May 3 16:01:40 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/cf35ab9ac7e0f33e39af6af16ecf850e24c2cb79/ghc
>---------------------------------------------------------------
commit cf35ab9ac7e0f33e39af6af16ecf850e24c2cb79
Author: Andrew Martin <andrew.thaddeus at gmail.com>
Date: Wed Apr 25 21:01:25 2018 -0400
minor improvement to wording of warning against First. Add warning against Last
>---------------------------------------------------------------
cf35ab9ac7e0f33e39af6af16ecf850e24c2cb79
libraries/base/Data/Monoid.hs | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/libraries/base/Data/Monoid.hs b/libraries/base/Data/Monoid.hs
index d11eda8..aa3000a 100644
--- a/libraries/base/Data/Monoid.hs
+++ b/libraries/base/Data/Monoid.hs
@@ -95,7 +95,7 @@ import Data.Semigroup.Internal
--
-- In additional to being equivalent in the structural sense, the two
-- also have 'Monoid' instances that behave the same. This type will
--- be marked deprecated in GHC 8.8. It will be removed in GHC 8.10.
+-- be marked deprecated in GHC 8.8, and removed in GHC 8.10.
-- Users are advised to use the variant from "Data.Semigroup" and wrap
-- it in 'Maybe'.
newtype First a = First { getFirst :: Maybe a }
@@ -127,6 +127,16 @@ instance Monoid (First a) where
--
-- >>> getLast (Last (Just "hello") <> Last Nothing <> Last (Just "world"))
-- Just "world"
+--
+-- Use of this type is discouraged. Note the following equivalence:
+--
+-- > Data.Monoid.Last x === Maybe (Data.Semigroup.Last x)
+--
+-- In additional to being equivalent in the structural sense, the two
+-- also have 'Monoid' instances that behave the same. This type will
+-- be marked deprecated in GHC 8.8, and removed in GHC 8.10.
+-- Users are advised to use the variant from "Data.Semigroup" and wrap
+-- it in 'Maybe'.
newtype Last a = Last { getLast :: Maybe a }
deriving ( Eq -- ^ @since 2.01
, Ord -- ^ @since 2.01
More information about the ghc-commits
mailing list