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 Thu, Nov 3, 2011 at 3:30 AM, wren ng thornton <w...@freegeek.org> wrote:

> On 11/2/11 7:14 AM, Eugene Kirpichov wrote:
>
>> 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
>>
>
> 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.
>
>
> [1] http://hackage.haskell.org/**packages/archive/logfloat/0.**
> 12.1/doc/html/Data-Number-**RealToFrac.html<http://hackage.haskell.org/packages/archive/logfloat/0.12.1/doc/html/Data-Number-RealToFrac.html>
>
> --
> Live well,
> ~wren
>
>
> ______________________________**_________________
> Haskell-Cafe mailing list
> haskell-c...@haskell.org
> http://www.haskell.org/**mailman/listinfo/haskell-cafe<http://www.haskell.org/mailman/listinfo/haskell-cafe>
>



-- 
Eugene Kirpichov
Principal Engineer, Mirantis Inc. http://www.mirantis.com/
Editor, http://fprog.ru/
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Gtk2hs-devel mailing list
Gtk2hs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel

Reply via email to