X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Unsafe%2FCoerce.hs;h=421cdd0bdf89f0905674d5b4329d1116cee722b5;hb=41e8fba828acbae1751628af50849f5352b27873;hp=a90b1491503f7d9dc88ac4733f46e6de062b288f;hpb=7c0b04fd273621130062418bb764809c79488dd2;p=ghc-base.git diff --git a/Unsafe/Coerce.hs b/Unsafe/Coerce.hs index a90b149..421cdd0 100644 --- a/Unsafe/Coerce.hs +++ b/Unsafe/Coerce.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash #-} + ----------------------------------------------------------------------------- -- | -- Module : Unsafe.Coerce @@ -12,11 +14,22 @@ -- type to any other type. Needless to say, if you use this function, -- it is your responsibility to ensure that the old and new types have -- identical internal representations, in order to prevent runtime corruption. +-- +-- The types for which 'unsafeCoerce' is representation-safe may differ +-- from compiler to compiler (and version to version). +-- +-- * Documentation for correct usage in GHC will be found under +-- 'unsafeCoerce#' in GHC.Base (around which 'unsafeCoerce' is just a +-- trivial wrapper). +-- +-- * In nhc98, the only representation-safe coercions are between Enum +-- types with the same range (e.g. Int, Int32, Char, Word32), +-- or between a newtype and the type that it wraps. module Unsafe.Coerce (unsafeCoerce) where #if defined(__GLASGOW_HASKELL__) -import GHC.Base (unsafeCoerce#) +import GHC.Prim (unsafeCoerce#) unsafeCoerce :: a -> b unsafeCoerce = unsafeCoerce# #endif @@ -26,5 +39,5 @@ import NonStdUnsafeCoerce (unsafeCoerce) #endif #if defined(__HUGS__) -import Hugs.Base (unsafeCoerce) +import Hugs.IOExts (unsafeCoerce) #endif