Skip to content

"A lazy (~) pattern cannot bind existential type variables" happens for non-existential GADTs

This program:

{-# LANGUAGE GADTs #-}
module Foo where

data Foo a where
   Foo :: a -> Foo (a, Int)

foo :: Foo (a, Int) -> a
foo ~(Foo a) = a

causes this error:

Foo.hs:8:4:
    A lazy (~) pattern cannot bind existential type variables
      `a' is a rigid type variable bound by
          the constructor `Foo' at Foo.hs:8:6
    In the pattern: ~(Foo a)
    In the definition of `foo': foo ~(Foo a) = a

This doesn't seem like an existential, as there aren't any type variables in the arguments to Foo that aren't in the result type.

If easy it would be nice if the restriction were relaxed to allow for this case, otherwise I think the error message should be improved.

Tested with ghc 6.10.1.20081209 and ghc 6.11.20090107.

Trac metadata
Trac field Value
Version 6.10.1
Type Bug
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