From 679863b0b48d76559507e4d1d9d52bafabd700e0 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Thu, 11 Feb 2010 21:35:41 -0500 Subject: [PATCH] floating: Punt the FFI newtype wrappers. Newtypes aren't supposed to change underlying representation, so they should be unnecessary. Indeed, things still seem to work without them. --- Data/Floating/Types.hs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Data/Floating/Types.hs b/Data/Floating/Types.hs index 5db5555..d0274a7 100644 --- a/Data/Floating/Types.hs +++ b/Data/Floating/Types.hs @@ -32,16 +32,6 @@ data Double = D# Double# -- | The Float type. data Float = F# Float# --- | This type is identical to CDouble. For some reason unknown to me, it is --- impossible to marshal data from Double to CDouble without losing --- information. The issue is further complicated by Foreign.C.Types not --- exporting CDouble's constructor. Thus, to marshal data from Double to --- CDouble, we construct an instance of this type and then use unsafeCoerce. -newtype FuckFFIDouble = FuckD Double - --- | The analogue of FuckFFIDouble for CFloat. -newtype FuckFFIFloat = FuckF Float - -- | Coercion to floating point types. class FloatConvert a b where -- | Convert to a floating point type. Conversions from integers and real @@ -51,16 +41,16 @@ class FloatConvert a b where toFloating :: a -> b instance FloatConvert Double CDouble where - toFloating = unsafeCoerce . FuckD + toFloating = unsafeCoerce instance FloatConvert CDouble Double where - toFloating f = let FuckD x = unsafeCoerce f in x + toFloating = unsafeCoerce instance FloatConvert Float CFloat where - toFloating = unsafeCoerce . FuckF + toFloating = unsafeCoerce instance FloatConvert CFloat Float where - toFloating f = let FuckF x = unsafeCoerce f in x + toFloating = unsafeCoerce instance FloatConvert Double Float where toFloating (D# x) = F# (double2Float# x) -- 2.11.4.GIT