Skip to content

No easy way to add cost-centre to top-levels

As far as I can see from the user manual (I also tried placing some SCCs), there's no way to easily add cost-centres to top-level definitions. We can do things like:

f x y z = ...
=>
f = {-# SCC f #-} \x y z -> ...

but it becomes too much work once we have "equations" style definitions like

head [] = {-# SCC head #-} Nothing
head (x : _) = {-# SCC head #-} Just x

Also, where clauses work differently after the transformations. Example:

f x y z = ...
  where <can use x and y here>
=>
f = {-# SCC f #-} \x y z -> ...
  where <can't use x and y here>

So it gets annoying real quick. It'd be really great if we could just add {-# SCC ... #-} just like {-# INLINE ... #-} pragmas.

Any ideas/opinions?

Looking at the code, it seems like -fprof-auto and similar flags are adding ticks to FunBind.fun_tick. We could do the same with this new SCC pragma.

Trac metadata
Trac field Value
Version 8.0.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information