what is `unsafeCoerce` in c++ and rust? - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

rednaZ

dear c++ experts, dear rust experts, what is unsafeCoerce in those languages?

rednaZ

ah, i guess you can do reinterpret_cast<T&> in c++. but does that really not generate any code?

TheMatten

rednaZ said:

dear c++ experts, dear rust experts, what is unsafeCoerce in those languages?

In rust it's std::mem::transmute

TheMatten

But I would say unsafeCoerce is slightly safer, because it assumes LiftedRep type representation (basically, normal data constructors), while transmute operates on any type with any representation, which is closer to unsafeCoerce# primop