[Haskell-cafe] SpecConstr message while compiling

Daniel Fischer daniel.is.fischer at googlemail.com
Sun Oct 23 19:50:02 CEST 2011

On Sunday 23 October 2011, 19:33:55, Daniel Díaz Casanueva wrote:
> Hi, cafe!
> I wrote a program and had the following message while compiling (with
> -O2):
> SpecConstr
>     Function `addOc{v s6RL} [lid]'
>       has four call patterns, but the limit is 3
>     Use -fspec-constr-count=n to set the bound
>     Use -dppr-debug to see specialisations
> What it means? Is it bad? It only happens when compiling with -O2.

It's nothing serious.
It's just a message (that accidentally was output by default in the 7.0.* 
series) that the spec-constr pass could have done more specialising, but 
the limit forbade it.

More specialising on constructors means

- certainly bigger code
- potentially faster code

but it could also become slower (most likely because of worse cache 

It's not even a warning, just a notification.

> addOc is a local function (defined in a where clause). If it helps, here
> is the definition:
> addOc x [] = [(x,1)]
> addOc x ((y,n):ys) = if x == y then (y,n+1) : ys
>                                else (y,n) : addOc x ys
> I want to know if there is something wrong or a I don't need to take
> care about this.

You need not take care of it, but you can try out and pass
on the command line (here, N = 4 is a good start) to see if the generated 
code is faster.

> Thanks in advance,
> Daniel Díaz.

More information about the Haskell-Cafe mailing list