diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-03-02 17:28:08 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-03-03 13:48:41 -0500 |
commit | e0c3e757becc9bcc1852c1e14fa7d65c7d2b7b00 (patch) | |
tree | eeee186db3ae358d2ccae2b7eeb6f8c399e0c008 | |
parent | ce65d0cceda4a028f30deafa3c39d40a250acc6a (diff) | |
download | haskell-e0c3e757becc9bcc1852c1e14fa7d65c7d2b7b00.tar.gz |
docs: Add note to unsafeCoerce function that you might want to use coerce [skip ci]
Fixes #15429
-rw-r--r-- | libraries/base/Unsafe/Coerce.hs | 4 |
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 |