[Git][ghc/ghc][wip/enumerate] base: Introduce Data.Enum.enumerate
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Sat Sep 23 13:10:43 UTC 2023
Ben Gamari pushed to branch wip/enumerate at Glasgow Haskell Compiler / GHC
Commits:
15b798e6 by Ben Gamari at 2023-09-23T09:10:35-04:00
base: Introduce Data.Enum.enumerate
As proposed in https://github.com/haskell/core-libraries-committee/issues/208.
- - - - -
6 changed files:
- libraries/base/Data/Enum.hs
- libraries/base/changelog.md
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
Changes:
=====================================
libraries/base/Data/Enum.hs
=====================================
@@ -17,6 +17,13 @@
module Data.Enum
( Bounded(..)
, Enum(..)
+ , enumerate
) where
import GHC.Enum
+
+-- | A list of all elements between 'minBound' and 'maxBound', inclusively.
+--
+-- @since 4.19.0.0
+enumerate :: (Enum a, Bounded a) => [a]
+enumerate = [minBound .. maxBound]
=====================================
libraries/base/changelog.md
=====================================
@@ -5,6 +5,7 @@
* Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #174](https://github.com/haskell/core-libraries-committee/issues/175))
* The `Enum Int64` and `Enum Word64` instances now use native operations on 32-bit platforms, increasing performance by up to 1.5x on i386 and up to 5.6x with the JavaScript backend. ([CLC proposal #187](https://github.com/haskell/core-libraries-committee/issues/187))
* Update to [Unicode 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/).
+ * The `Data.Enum` module has been added, exposing the existing `Bounded` and `Enum` typeclasses, as well as the the new `enumerate :: (Enum a, Bounded a) => [a]` ([CLC proposal #208](https://github.com/haskell/core-libraries-committee/issues/208))
## 4.19.0.0 *TBA*
* Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`.
=====================================
testsuite/tests/interface-stability/base-exports.stdout
=====================================
@@ -924,6 +924,7 @@ module Data.Enum where
enumFromTo :: a -> a -> [a]
enumFromThenTo :: a -> a -> a -> [a]
{-# MINIMAL toEnum, fromEnum #-}
+ enumerate :: forall a. (Enum a, Bounded a) => [a]
module Data.Eq where
-- Safety: Trustworthy
=====================================
testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
=====================================
@@ -924,6 +924,7 @@ module Data.Enum where
enumFromTo :: a -> a -> [a]
enumFromThenTo :: a -> a -> a -> [a]
{-# MINIMAL toEnum, fromEnum #-}
+ enumerate :: forall a. (Enum a, Bounded a) => [a]
module Data.Eq where
-- Safety: Trustworthy
=====================================
testsuite/tests/interface-stability/base-exports.stdout-mingw32
=====================================
@@ -924,6 +924,7 @@ module Data.Enum where
enumFromTo :: a -> a -> [a]
enumFromThenTo :: a -> a -> a -> [a]
{-# MINIMAL toEnum, fromEnum #-}
+ enumerate :: forall a. (Enum a, Bounded a) => [a]
module Data.Eq where
-- Safety: Trustworthy
=====================================
testsuite/tests/interface-stability/base-exports.stdout-ws-32
=====================================
@@ -924,6 +924,7 @@ module Data.Enum where
enumFromTo :: a -> a -> [a]
enumFromThenTo :: a -> a -> a -> [a]
{-# MINIMAL toEnum, fromEnum #-}
+ enumerate :: forall a. (Enum a, Bounded a) => [a]
module Data.Eq where
-- Safety: Trustworthy
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15b798e62f91858e7bcb88214a1ae8f38c588e3d
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15b798e62f91858e7bcb88214a1ae8f38c588e3d
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/20230923/569ab9c3/attachment-0001.html>
More information about the ghc-commits
mailing list