Misleading documentation on Data.Semigroup.First
Summary
Location of documentation issue: https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Monoid.html#t:First
The documentation for Data.Monoid.First
mentions that Data.Monoid.First x === Maybe (Data.Semigroup.First x)
, but they are only semantically equivalent, they have different strictness properties.
module Main where
import qualified Data.Monoid as M
import qualified Data.Semigroup as S
main :: IO ()
main = do
print $ foldMap (M.First . Just) [1 :: Int .. ]
print $ foldMap (S.Option . Just . S.First) [1 :: Int .. ]
print $ foldMap (Just . S.First) [1 :: Int .. ]
The example above shows the behavior, the first line has a result of First (Just 1)
, but all the rest fail for stack overflow.
Proposed improvements or changes
I would like to see some kind of warning about the change in performance in some situations.
Environment
- GHC version used (if appropriate): 8.8.3