42567a9fa1d5e6d2b578f6615cc3c98cb31a8322
[haskell-directory.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 module Unsafe.Coerce (unsafeCoerce) where
18
19 #if defined(__GLASGOW_HASKELL__)
20 import GHC.Base (unsafeCoerce#)
21 unsafeCoerce :: a -> b
22 unsafeCoerce = unsafeCoerce#
23 #endif
24
25 #if defined(__NHC__)
26 import NonStdUnsafeCoerce (unsafeCoerce)
27 #endif
28
29 #if defined(__HUGS__)
30 import Hugs.IOExts (unsafeCoerce)
31 #endif