Skip to content

SCC annotations cause compile errors

The following program will not compile:

bad s = take 10 . {-# SCC "foo" #-} drop 10 $ s

It fails with the message

    Couldn't match expected type `a -> [a1]'                                                           
           against inferred type `[a2]'                                                                
    In the second argument of `(.)', namely `(drop 10 $ s)'                                            
    In the expression: take 10 . (drop 10 $ s)                                                         
    In the definition of `bad': bad s = take 10 . (drop 10 $ s)

However, if the SCC annotation is removed it compiles:

good s = take 10 . drop 10 $ s

Adding parentheses can also fix it:

good2 s = take 10 . ({-# SCC "foo" #-} drop 10) $ s

but it's still annoying that adding an annotation can cause compilation to fail.

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