Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,862
    • Issues 4,862
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 455
    • Merge requests 455
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #2899
Closed
Open
Created Dec 26, 2008 by jochemb@trac-jochemb

GADT type inference with existentials

The following code works in GHC 6.8.2:

{-# OPTIONS -fglasgow-exts #-}
module Test where

data Existential = forall a. Ex (GADT a)

data GADT :: * -> * where
        GCon :: Int -> GADT ()

-- g :: Existential -> Int
g (Ex (GCon x)) = x

The compiler correctly infers the type of x in the definition of g, and correctly infers the type of g.

In GHC 6.10.1, however, this fails with:

Test.hs:10:12:
    GADT pattern match with non-rigid result type `t'
      Solution: add a type signature
    In the definition of `g': g (Ex (GCon x)) = x
Failed, modules loaded: none.

The solution, to include the type signature of g (that I have commented out), works, but why can't GHC figure out the type of g? GHC 6.8.2 could!

An equivalent version with a non-GADT instead, works correctly:

data GADT a = GCon Int

Ticket #2206 (closed) might be related.

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
Assignee
Assign to
Time tracking