Skip to content

'Untouchable' error in list comprehension

Hi,

I think this program should compile but it doesn't:

{-# LANGUAGE GADTs #-}

data X a where X :: X Int

foo :: Bool
foo = null [ () | X <- [] ]

It fails with:

    Couldn't match expected type `a0' with actual type `()'
      `a0' is untouchable
           inside the constraints (t_g ~ Int)
           bound at a pattern with constructor
                      X :: X Int,
                    in a pattern binding in
                         list comprehension
    In the pattern: X
    In a stmt of a list comprehension: X <- []
    In the first argument of `null', namely `[() | X <- []]'

If I remove the type declaration GHC compiles without errors and happily infers foo :: Bool.

Trac metadata
Trac field Value
Version 7.6.3
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