Commit 113d50b7 authored by Ryan Scott's avatar Ryan Scott
Browse files

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
parent d6102743
......@@ -100,6 +100,9 @@ See ``changelog.md`` in the ``base`` package for full release notes.
- ``Data.Either`` now provides ``fromLeft`` and ``fromRight``
- ``Data.Type.Coercion`` now provides ``gcoerceWith``, which is analogous to
``gcastWith`` from ``Data.Type.Equality``.
binary
~~~~~~
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment