Skip to content
  • rl@cse.unsw.edu.au's avatar
    Add new ForceSpecConstr annotation · 1935c449
    rl@cse.unsw.edu.au authored
    Annotating a type with {-# ANN type T ForceSpecConstr #-} makes SpecConstr
    ignore -fspec-constr-threshold and -fspec-constr-count for recursive functions
    that have arguments of type T. Such functions will be specialised regardless
    of their size and there is no upper bound on the number of specialisations
    that can be generated. This also works if T is embedded in other types such as
    Maybe T (but not T -> T).
    
    T should not be a product type because it could be eliminated by the
    worker/wrapper transformation. For instance, in
    
    data T = T Int Int
    
    foo :: T -> Int
    foo (T m n) = ... foo (T m' n') ...
    
    SpecConstr will never see the T because w/w will get rid of it. I'm still
    thinking about whether fixing this is worthwhile.
    1935c449