[commit: ghc] master: Warn against using Data.Monoid.First (e34e30e)

git at git.haskell.org git at git.haskell.org
Thu May 3 16:01:11 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/e34e30e492a7bc40e3da5a05b8e297acb0aeeadc/ghc

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

commit e34e30e492a7bc40e3da5a05b8e297acb0aeeadc
Author: Andrew Martin <andrew.thaddeus at gmail.com>
Date:   Wed Apr 25 19:35:36 2018 -0400

    Warn against using Data.Monoid.First
    
    Noting that it will be removed in the future.


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

e34e30e492a7bc40e3da5a05b8e297acb0aeeadc
 libraries/base/Data/Monoid.hs | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libraries/base/Data/Monoid.hs b/libraries/base/Data/Monoid.hs
index b6d09c1..d11eda8 100644
--- a/libraries/base/Data/Monoid.hs
+++ b/libraries/base/Data/Monoid.hs
@@ -88,6 +88,16 @@ import Data.Semigroup.Internal
 --
 -- >>> getFirst (First (Just "hello") <> First Nothing <> First (Just "world"))
 -- Just "hello"
+--
+-- Use of this type is discouraged. Note the following equivalence:
+--
+-- > Data.Monoid.First x === Maybe (Data.Semigroup.First 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. It will be 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 }
         deriving ( Eq          -- ^ @since 2.01
                  , Ord         -- ^ @since 2.01



More information about the ghc-commits mailing list