Skip to content
GitLab
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 5,246
    • Issues 5,246
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 562
    • Merge requests 562
  • 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 CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16330
Closed
Open
Issue created Feb 16, 2019 by Sasha Bogicevic@Bogicevic💬Developer

Type inference in presence of pattern matching on GADTs

This small example

{-# LANGUAGE GADTs #-}

data G a where
   I :: G Integer

f g = case g of I -> ()

yields

    • Couldn't match expected type ‘p’ with actual type ‘()’
        ‘p’ is untouchable
          inside the constraints: a ~ Integer
          bound by a pattern with constructor: I :: G Integer,
                   in a case alternative
          at gadtsInference.hs:6:17
      ‘p’ is a rigid type variable bound by
        the inferred type of f :: G a -> p
        at gadtsInference.hs:6:1-23
      Possible fix: add a type signature for ‘f’
    • In the expression: ()
      In a case alternative: I -> ()
      In the expression: case g of { I -> () }
    • Relevant bindings include
        f :: G a -> p (bound at gadtsInference.hs:6:1)
  |
6 | f g = case g of I -> ()
  |                      ^^

Without providing the type annotation for f f :: G a -> () GHC cannot infer the correct result type.

Trac metadata
Trac field Value
Version 8.6.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority low
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
Assignee
Assign to
Time tracking