Skip to content

Regression in type checking of sections in records

Looks like a GHC 6.10 regression.

The following code, from xmonad-contrib, fails with an error under 6.10, but not under other compilers,

[ 74 of 138] Compiling XMonad.Hooks.UrgencyHook ( XMonad/Hooks/UrgencyHook.hs, dist/build/XMonad/Hooks/UrgencyHook.o )

XMonad/Hooks/UrgencyHook.hs:424:48:
    The section `5 `seconds`' takes one argument,
    but its type `Int' has none
    In the `duration' field of a record
    In the expression:
        DzenUrgencyHook {duration = (5 `seconds`), args = []}
    In the definition of `dzenUrgencyHook':
        dzenUrgencyHook = DzenUrgencyHook
                            {duration = (5 `seconds`), args = []}

The relevant code is:

-- | Flashes when a window requests your attention and you can't see it.
-- Defaults to a duration of five seconds, and no extra args to dzen.
-- See 'DzenUrgencyHook'.
dzenUrgencyHook :: DzenUrgencyHook
dzenUrgencyHook = DzenUrgencyHook { duration = (5 `seconds`), args = [] }

Which looks harmless enough. In fact, rearranging the section let's it pass type checking:

dzenUrgencyHook = DzenUrgencyHook { duration = seconds 5, args = [] }

The relevant code can be found here: http://code.haskell.org/XMonadContrib/XMonad/Hooks/UrgencyHook.hs, line 424.

To reproduce, assuming ghc 6.10 is installed, and X11,

$ cd XMonadContrib 
$ cabal install
Trac metadata
Trac field Value
Version 6.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
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