[Git][ghc/ghc][master] Add heqT, a kind-heterogeneous variant of heq

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Sun Dec 11 17:26:34 UTC 2022



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


Commits:
b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00
Add heqT, a kind-heterogeneous variant of heq

CLC proposal https://github.com/haskell/core-libraries-committee/issues/99

- - - - -


2 changed files:

- libraries/base/Data/Typeable.hs
- libraries/base/changelog.md


Changes:

=====================================
libraries/base/Data/Typeable.hs
=====================================
@@ -4,6 +4,7 @@
 {-# LANGUAGE PolyKinds #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-# LANGUAGE Trustworthy #-}
+{-# LANGUAGE TypeApplications #-}
 {-# LANGUAGE TypeOperators #-}
 
 -----------------------------------------------------------------------------
@@ -56,6 +57,7 @@ module Data.Typeable
       -- * Type-safe cast
     , cast
     , eqT
+    , heqT
     , gcast                -- a generalisation of cast
 
       -- * Generalized casts for higher-order kinds
@@ -135,8 +137,14 @@ cast x
 -- @since 4.7.0.0
 eqT :: forall a b. (Typeable a, Typeable b) => Maybe (a :~: b)
 eqT
-  | Just HRefl <- ta `I.eqTypeRep` tb = Just Refl
-  | otherwise                         = Nothing
+  | Just HRefl <- heqT @a @b = Just Refl
+  | otherwise                = Nothing
+
+-- | Extract a witness of heterogeneous equality of two types
+--
+-- @since 4.18.0.0
+heqT :: forall a b. (Typeable a, Typeable b) => Maybe (a :~~: b)
+heqT = ta `I.eqTypeRep` tb
   where
     ta = I.typeRep :: I.TypeRep a
     tb = I.typeRep :: I.TypeRep b


=====================================
libraries/base/changelog.md
=====================================
@@ -57,6 +57,7 @@
     of individually allocated pointers as well as freeing each one of them when
     freeing a `Pool`. (#14762) (#18338)
   * `Type.Reflection.Unsafe` is now marked as unsafe.
+  * Add `Data.Typeable.heqT`, a kind-heterogeneous version of `Data.Typeable.eqT`.
 
 ## 4.17.0.0 *August 2022*
 



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3e98a926ac05b8e59e3b31b74b019d4ecb462f6
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/20221211/541d684e/attachment-0001.html>


More information about the ghc-commits mailing list