[Haskell-cafe] Fwd: Ridiculously slow FFI, or cairo binding?

Eugene Kirpichov ekirpichov at gmail.com
Thu Nov 3 05:03:07 CET 2011


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 <wren at 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-Cafe at 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/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111103/56a877a0/attachment.htm>


More information about the Haskell-Cafe mailing list