[Haskell-beginners] Double vs. Num

Christopher Allen cma at bitemyapp.com
Wed May 4 23:12:31 UTC 2016


The default if it’s a Floating type is Double. Leaving the type polymorphic breaks sharing, though, and that’s a common cause of perf issues with Num/Integral/Floating a => a computations.

Best to post code when asking questions like this.

> On May 4, 2016, at 6:08 PM, Tim Perry <tim.v2.0 at gmail.com> wrote:
> 
> I imagine that in this program when Double isn't specified the compiler doesn't assign a "hardware optimized" number type. Consequently it isn't using the specialized functions that are used for 64-bit floating point numbers. When the program specifies it is receiving the "Double" values, then it does use the "hardware optimized" data types.
> 
> On Wed, May 4, 2016 at 3:12 PM, Ben Rogalski <bwrogalski at gmail.com <mailto:bwrogalski at gmail.com>> wrote:
> I have found that using the type Double in a type signature causes my program to run much faster than if I use a type variable with a Num constraint.
> 
> Is this common, and if so, why is explicitly using Double faster?
> 
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org <mailto:Beginners at haskell.org>
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners <http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners>
> 
> 
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160504/0fae17d8/attachment.html>


More information about the Beginners mailing list