Thanks! I'll definitely consider your library in the future, but for now, as we can see, there's no necessity in rewriting cFloatConv at all - {-# INLINE #-} suffices :)
On 11/2/11 7:14 AM, Eugene Kirpichov wrote:If you're going the MPTC route, I suggest you use logfloat:Data.Number.RealToFrac[1]. I don't have the CDouble and CFloat instances, but I could add them. The instances themselves are only moderately more clever than yours ---namely using CPP for portability to non-GHC compilers--- but I think it's good for people to rally around one implementation of the solution instead of having a bunch of copies of the same thing, each poorly maintained because of the distributedness.
I rewrote cFloatConv like this:
import GHC.Float
class (RealFloat a, RealFloat b) => CFloatConv a b where
cFloatConv :: a -> b
cFloatConv = realToFrac
instance CFloatConv Double Double where cFloatConv = id
instance CFloatConv Double CDouble
instance CFloatConv CDouble Double
instance CFloatConv Float Float where cFloatConv = id
instance CFloatConv Float Double where cFloatConv = float2Double
instance CFloatConv Double Float where cFloatConv = double2Float
[1] http://hackage.haskell.org/packages/archive/logfloat/0.12.1/doc/html/Data-Number-RealToFrac.html
--
Live well,
~wren
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe