[Git][ghc/ghc][master] Add Foldable1 Solo instance

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Sat Jan 28 07:58:59 UTC 2023



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


Commits:
082b7d43 by Oleg Grenrus at 2023-01-28T02:58:38-05:00
Add Foldable1 Solo instance

- - - - -


1 changed file:

- libraries/base/Data/Foldable1.hs


Changes:

=====================================
libraries/base/Data/Foldable1.hs
=====================================
@@ -32,6 +32,7 @@ import Data.List.NonEmpty (NonEmpty (..))
 import Data.Semigroup
        (Dual (..), First (..), Last (..), Max (..), Min (..), Product (..),
        Semigroup (..), Sum (..))
+import GHC.Tuple          (Solo (..))
 import Prelude
        (Maybe (..), Monad (..), Ord, Ordering (..), id, seq, ($!), ($), (.),
        (=<<), flip, const, error)
@@ -388,6 +389,14 @@ instance Foldable1 Complex where
 
 -- 3+ tuples are not Foldable/Traversable
 
+instance Foldable1 Solo where
+    foldMap1 f (MkSolo y) = f y
+    toNonEmpty (MkSolo x) = x :| []
+    minimum (MkSolo x) = x
+    maximum (MkSolo x) = x
+    head (MkSolo x) = x
+    last (MkSolo x) = x
+
 instance Foldable1 ((,) a) where
     foldMap1 f (_, y) = f y
     toNonEmpty (_, x) = x :| []



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/082b7d43ee4b8203dc9bca53e5e1f7a45c42eeb8

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/082b7d43ee4b8203dc9bca53e5e1f7a45c42eeb8
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/20230128/b98df2c6/attachment-0001.html>


More information about the ghc-commits mailing list