From 7c0b04fd273621130062418bb764809c79488dd2 Mon Sep 17 00:00:00 2001 From: "Malcolm.Wallace@cs.york.ac.uk" Date: Mon, 13 Nov 2006 11:41:03 +0000 Subject: [PATCH] put 'unsafeCoerce' in a standard location --- Unsafe/Coerce.hs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Unsafe/Coerce.hs diff --git a/Unsafe/Coerce.hs b/Unsafe/Coerce.hs new file mode 100644 index 0000000..a90b149 --- /dev/null +++ b/Unsafe/Coerce.hs @@ -0,0 +1,30 @@ +----------------------------------------------------------------------------- +-- | +-- Module : Unsafe.Coerce +-- Copyright : Malcolm Wallace 2006 +-- License : BSD-style (see the LICENSE file in the distribution) +-- +-- Maintainer : libraries@haskell.org +-- Stability : experimental +-- Portability : portable +-- +-- The highly unsafe primitive 'unsafeCoerce' converts a value from any +-- 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. + +module Unsafe.Coerce (unsafeCoerce) where + +#if defined(__GLASGOW_HASKELL__) +import GHC.Base (unsafeCoerce#) +unsafeCoerce :: a -> b +unsafeCoerce = unsafeCoerce# +#endif + +#if defined(__NHC__) +import NonStdUnsafeCoerce (unsafeCoerce) +#endif + +#if defined(__HUGS__) +import Hugs.Base (unsafeCoerce) +#endif -- 1.7.10.4