Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,324
    • Issues 4,324
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 373
    • Merge Requests 373
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16278

Closed
Open
Opened Feb 02, 2019 by Andrew Martin@andrewthadDeveloper

Exhaustivity checking GADT with free variables

Consider the following example:

{-# language DataKinds #-}
{-# language TypeFamilies #-}
{-# language GADTs #-}
{-# language KindSignatures #-}

{-# OPTIONS_GHC -Wall -fforce-recomp #-}

module GadtException where

import Data.Kind (Type)
import GHC.Exts

data Send = Send

data SocketException :: Send -> Type where 
  LocalShutdown :: SocketException 'Send
  OutOfMemory :: SocketException a

someSocketException :: SocketException a
someSocketException = OutOfMemory

foo :: Int
foo = case someSocketException :: SocketException Any of
  LocalShutdown -> 2
  OutOfMemory -> 1

In foo, GHC's exhaustivity checker requires a pattern match on LocalShutdown. However, LocalShutdown is not an inhabitant of SocketException Any. What I would really like is for this to go one step further. I shouldn't even need to write the type annotation. That is, with the above code otherwise unchanged, GHC should recognize that

foo :: Int
foo = case someSocketException of
  OutOfMemory -> 1

handles all possible cases. Since fully polymorphic type variables become Any at some point during typechecking, I would expect that if this worked with the SocketException Any type signature, it would work without it.

Trac metadata
Trac field Value
Version 8.6.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#16278