summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-03-02 17:28:08 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2022-03-03 09:55:12 +0000
commit12487340c1a37fb90003f54fd910ef762fa4b17d (patch)
tree1c7a67469387ea8a294afcde003c877d3c09fdb8
parentaeea6bd588060108dea88996c19f48b9e50adad2 (diff)
downloadhaskell-wip/coerce-docs.tar.gz
docs: Add note to unsafeCoerce function that you might want to use coerce [skip ci]wip/coerce-docs
Fixes #15429
-rw-r--r--libraries/base/Unsafe/Coerce.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/libraries/base/Unsafe/Coerce.hs b/libraries/base/Unsafe/Coerce.hs
index 930514ce81..ec5b793f87 100644
--- a/libraries/base/Unsafe/Coerce.hs
+++ b/libraries/base/Unsafe/Coerce.hs
@@ -267,6 +267,10 @@ unsafeEqualityProof = case unsafeEqualityProof @a @b of UnsafeRefl -> UnsafeRefl
-- (which have different kinds!) because it's really just a newtype.
-- Note: there is /no guarantee, at all/ that this behavior will be supported
-- into perpetuity.
+--
+--
+-- For safe zero-cost coercions you can instead use the 'Data.Coerce.coerce' function from
+-- "Data.Coerce".
unsafeCoerce :: forall (a :: Type) (b :: Type) . a -> b
unsafeCoerce x = case unsafeEqualityProof @a @b of UnsafeRefl -> x