diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2016-08-18 09:11:03 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2016-08-18 09:11:03 -0400 |
commit | 113d50b791c469394d38fab6ce5b760e5e8c35e2 (patch) | |
tree | 74ce30e83d9bcfc54de7875f9fc7c5223f4aa779 /libraries | |
parent | d61027438102e212c47721306d4f294278e95b57 (diff) | |
download | haskell-113d50b791c469394d38fab6ce5b760e5e8c35e2.tar.gz |
Add gcoerceWith to Data.Type.Coercion
Summary:
For symmetry with `gcastWith` in `Data.Type.Equality`.
Fixes #12493.
Test Plan: It compiles
Reviewers: bgamari, goldfire, hvr, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2456
GHC Trac Issues: #12493
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/Data/Type/Coercion.hs | 8 | ||||
-rw-r--r-- | libraries/base/changelog.md | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/libraries/base/Data/Type/Coercion.hs b/libraries/base/Data/Type/Coercion.hs index 254bb9aecf..318d0983f2 100644 --- a/libraries/base/Data/Type/Coercion.hs +++ b/libraries/base/Data/Type/Coercion.hs @@ -7,6 +7,7 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} ----------------------------------------------------------------------------- -- | @@ -25,6 +26,7 @@ module Data.Type.Coercion ( Coercion(..) , coerceWith + , gcoerceWith , sym , trans , repr @@ -56,6 +58,12 @@ data Coercion a b where coerceWith :: Coercion a b -> a -> b coerceWith Coercion x = coerce x +-- | Generalized form of type-safe cast using representational equality +-- +-- @since 4.10.0.0 +gcoerceWith :: Coercion a b -> (Coercible a b => r) -> r +gcoerceWith Coercion x = x + -- | Symmetry of representational equality sym :: Coercion a b -> Coercion b a sym Coercion = Coercion diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index 996456f0e6..f8f6b10f30 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -16,6 +16,8 @@ * `Data.Either` now provides `fromLeft` and `fromRight` (#12402) + * `Data.Type.Coercion` now provides `gcoerceWith` (#12493) + ## 4.9.0.0 *May 2016* * Bundled with GHC 8.0 |