[Haskell-cafe] Profiling nested case

Mitar mmitar at gmail.com
Fri Jul 18 11:28:10 EDT 2008


Hi!

On Fri, Jul 18, 2008 at 3:54 PM, Chaddaï Fouché
<chaddai.fouche at gmail.com> wrote:
>> So that I can easily change the type everywhere. But it would be much
>> nicer to write:
>>
>> data Quaternion a = Q !a !a !a !a deriving (Eq,Show)
>>
>> Only the performance of Num instance functions of Quaternion is then
>> quite worse.
>
> You can probably use a specialization pragma to get around that.

But why is this not automatic? If I use Quaternions of only one type
in the whole program then why it does not make specialized version for
it? At least with -O2 switch.

Why exactly are polymorphic functions slower? Is not this just a
question of type checking (and of writing portable/reusable code)? But
later on in a compiler process we do know of which type exactly is the
called function - so we could use a function as it would be written
only for that type. Something what specialization is doing as I see. I
thought this is always done.


Mitar


More information about the Haskell-Cafe mailing list