summaryrefslogtreecommitdiff
path: root/compiler/GHC/Builtin/primops.txt.pp
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Builtin/primops.txt.pp')
-rw-r--r--compiler/GHC/Builtin/primops.txt.pp44
1 files changed, 0 insertions, 44 deletions
diff --git a/compiler/GHC/Builtin/primops.txt.pp b/compiler/GHC/Builtin/primops.txt.pp
index e4283b2dda..e99e5dc3a3 100644
--- a/compiler/GHC/Builtin/primops.txt.pp
+++ b/compiler/GHC/Builtin/primops.txt.pp
@@ -3845,50 +3845,6 @@ pseudoop "seq"
-- This fixity is only the one picked up by Haddock. If you
-- change this, do update 'ghcPrimIface' in 'GHC.Iface.Load'.
-pseudoop "unsafeCoerce#"
- o -> p
- { The function 'unsafeCoerce#' allows you to side-step the typechecker entirely. That
- is, it allows you to coerce any type into any other type. If you use this function,
- you had better get it right, otherwise segmentation faults await. It is generally
- used when you want to write a program that you know is well-typed, but where Haskell's
- type system is not expressive enough to prove that it is well typed.
-
- The following uses of 'unsafeCoerce#' are supposed to work (i.e. not lead to
- spurious compile-time or run-time crashes):
-
- * Casting any lifted type to 'Any'
-
- * Casting 'Any' back to the real type
-
- * Casting an unboxed type to another unboxed type of the same size.
- (Casting between floating-point and integral types does not work.
- See the "GHC.Float" module for functions to do work.)
-
- * Casting between two types that have the same runtime representation. One case is when
- the two types differ only in "phantom" type parameters, for example
- @'Ptr' 'Int'@ to @'Ptr' 'Float'@, or @['Int']@ to @['Float']@ when the list is
- known to be empty. Also, a @newtype@ of a type @T@ has the same representation
- at runtime as @T@.
-
- Other uses of 'unsafeCoerce#' are undefined. In particular, you should not use
- 'unsafeCoerce#' to cast a T to an algebraic data type D, unless T is also
- an algebraic data type. For example, do not cast @'Int'->'Int'@ to 'Bool', even if
- you later cast that 'Bool' back to @'Int'->'Int'@ before applying it. The reasons
- have to do with GHC's internal representation details (for the cognoscenti, data values
- can be entered but function closures cannot). If you want a safe type to cast things
- to, use 'Any', which is not an algebraic data type.
-
- }
- with can_fail = True
-
--- NB. It is tempting to think that casting a value to a type that it doesn't have is safe
--- as long as you don't "do anything" with the value in its cast form, such as seq on it. This
--- isn't the case: the compiler can insert seqs itself, and if these happen at the wrong type,
--- Bad Things Might Happen. See bug #1616: in this case we cast a function of type (a,b) -> (a,b)
--- to () -> () and back again. The strictness analyser saw that the function was strict, but
--- the wrapper had type () -> (), and hence the wrapper de-constructed the (), the worker re-constructed
--- a new (), with the result that the code ended up with "case () of (a,b) -> ...".
-
primop TraceEventOp "traceEvent#" GenPrimOp
Addr# -> State# s -> State# s
{ Emits an event via the RTS tracing framework. The contents