foundation icon indicating copy to clipboard operation
foundation copied to clipboard

unsafeCoerce# will be gone in GHC 8.12

Open sgraf812 opened this issue 5 years ago • 3 comments

Just a heads up: I realised through a broken build with a recent GHC HEAD that basement uses unsafeCoerce# (rather than unsafeCoerce). That primop will be gone as of 8.12, see https://gitlab.haskell.org/ghc/ghc/-/merge_requests/1869 and the issues it fixes.

Sorry for the breakage, but primops AFAIK aren't really part of any versioning policy.

sgraf812 avatar Mar 26 '20 19:03 sgraf812

On the bright side, I don't see why you couldn't have used the regular unsafeCoerce in the first place. It doesn't seem like you are coercing between runtime representations (all three usages appear to coerce from lifted to lifted).

Edit: Well, that only applies to the unsafeCoerce# in Basement/Monad.hs

sgraf812 avatar Mar 26 '20 19:03 sgraf812

Apologies, I wasn't completely up to what !1869 does. Actually, we still have unsafeCoerce#, it is just no longer a primop, but wired in. You should import it through GHC.Exts, which is a backwards compatible change. I'm preparing a PR.

sgraf812 avatar Mar 26 '20 19:03 sgraf812

While unsafeCoerce# is indeed still around, I would still very strongly discourage its use. It's an incredibly unsafe function which has very few uses. We have considered removing it for this reason and may do so in the future (after adding a pair of lifted-unlifted coercions, which is one of the few justifiable uses of unsafeCoerce#).

bgamari avatar Mar 31 '20 00:03 bgamari