b1cb11b9a1e5797b8751f1e0fbebc0c808caf082
[ghc-base.git] / Unsafe / Coerce.hs
1 {-# OPTIONS_GHC -fno-implicit-prelude #-}
2 -----------------------------------------------------------------------------
3 -- |
4 -- Module      :  Unsafe.Coerce
5 -- Copyright   :  Malcolm Wallace 2006
6 -- License     :  BSD-style (see the LICENSE file in the distribution)
7 --
8 -- Maintainer  :  libraries@haskell.org
9 -- Stability   :  experimental
10 -- Portability :  portable
11 --
12 -- The highly unsafe primitive 'unsafeCoerce' converts a value from any
13 -- type to any other type.  Needless to say, if you use this function,
14 -- it is your responsibility to ensure that the old and new types have
15 -- identical internal representations, in order to prevent runtime corruption.
16 --
17 -- 'unsafeCoerce' is just a trivial wrapper for 'unsafeCoerce#';
18 -- see the latter for important documetation about correct usage.
19
20 module Unsafe.Coerce (unsafeCoerce) where
21
22 #if defined(__GLASGOW_HASKELL__)
23 import GHC.Base (unsafeCoerce#)
24 unsafeCoerce :: a -> b
25 unsafeCoerce = unsafeCoerce#
26 #endif
27
28 #if defined(__NHC__)
29 import NonStdUnsafeCoerce (unsafeCoerce)
30 #endif
31
32 #if defined(__HUGS__)
33 import Hugs.IOExts (unsafeCoerce)
34 #endif