[commit: ghc] master: base: Derive Enum, Bounded for VecCount, VecElem (5cb5b7a)

git at git.haskell.org git at git.haskell.org
Thu Feb 2 04:38:10 UTC 2017


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

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

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

commit 5cb5b7a505d3cf87b4bdac31acae2a650221d05f
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Wed Feb 1 22:48:01 2017 -0500

    base: Derive Enum, Bounded for VecCount, VecElem
    
    
    Test Plan: Validate
    
    Reviewers: RyanGlScott, austin, hvr
    
    Reviewed By: RyanGlScott
    
    Subscribers: goldfire, RyanGlScott, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3059


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

5cb5b7a505d3cf87b4bdac31acae2a650221d05f
 compiler/prelude/TysWiredIn.hs  |  4 ++--
 libraries/base/GHC/Enum.hs      | 12 ++++++++++++
 libraries/base/changelog.md     |  2 ++
 libraries/ghc-prim/GHC/Types.hs |  2 ++
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/compiler/prelude/TysWiredIn.hs b/compiler/prelude/TysWiredIn.hs
index 66eb396..b238201 100644
--- a/compiler/prelude/TysWiredIn.hs
+++ b/compiler/prelude/TysWiredIn.hs
@@ -1168,7 +1168,7 @@ liftedRepDataConTy, unliftedRepDataConTy,
   = map (mkTyConTy . promoteDataCon) runtimeRepSimpleDataCons
 
 vecCountTyCon :: TyCon
-vecCountTyCon = pcNonEnumTyCon vecCountTyConName Nothing []
+vecCountTyCon = pcTyCon True vecCountTyConName Nothing []
                         vecCountDataCons
 
 -- See Note [Wiring in RuntimeRep]
@@ -1187,7 +1187,7 @@ vec2DataConTy, vec4DataConTy, vec8DataConTy, vec16DataConTy, vec32DataConTy,
   vec64DataConTy] = map (mkTyConTy . promoteDataCon) vecCountDataCons
 
 vecElemTyCon :: TyCon
-vecElemTyCon = pcNonEnumTyCon vecElemTyConName Nothing [] vecElemDataCons
+vecElemTyCon = pcTyCon True vecElemTyConName Nothing [] vecElemDataCons
 
 -- See Note [Wiring in RuntimeRep]
 vecElemDataCons :: [DataCon]
diff --git a/libraries/base/GHC/Enum.hs b/libraries/base/GHC/Enum.hs
index 50ca4a0..feb4585 100644
--- a/libraries/base/GHC/Enum.hs
+++ b/libraries/base/GHC/Enum.hs
@@ -876,3 +876,15 @@ dn_list x0 delta lim = go (x0 :: Integer)
                     where
                         go x | x < lim   = []
                              | otherwise = x : go (x+delta)
+
+-- Instances from GHC.Types
+
+-- | @since 4.10.0.0
+deriving instance Bounded VecCount
+-- | @since 4.10.0.0
+deriving instance Enum VecCount
+
+-- | @since 4.10.0.0
+deriving instance Bounded VecElem
+-- | @since 4.10.0.0
+deriving instance Enum VecElem
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index 40e18ff..afb9e9f 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -199,6 +199,8 @@
   * The field `spInfoName` of `GHC.StaticPtr.StaticPtrInfo` has been removed.
     The value is no longer available when constructing the `StaticPtr`.
 
+  * `VecElem` and `VecCount` now have `Enum` and `Bounded` instances.
+
 ### Generalizations
 
   * Generalize `Debug.Trace.{traceM, traceShowM}` from `Monad` to `Applicative`
diff --git a/libraries/ghc-prim/GHC/Types.hs b/libraries/ghc-prim/GHC/Types.hs
index 16a4921..c913af6 100644
--- a/libraries/ghc-prim/GHC/Types.hs
+++ b/libraries/ghc-prim/GHC/Types.hs
@@ -395,6 +395,7 @@ data VecCount = Vec2
               | Vec16
               | Vec32
               | Vec64
+-- Enum, Bounded instances in GHC.Enum
 
 -- | Element of a SIMD vector type
 data VecElem = Int8ElemRep
@@ -407,6 +408,7 @@ data VecElem = Int8ElemRep
              | Word64ElemRep
              | FloatElemRep
              | DoubleElemRep
+-- Enum, Bounded instances in GHC.Enum
 
 {- *********************************************************************
 *                                                                      *



More information about the ghc-commits mailing list