Opened 5 years ago

Closed 5 years ago

#9433 closed bug (fixed)

Partially applied type family allowed but unusable

Reported by: hesselink Owned by:
Priority: normal Milestone: 7.8.4
Component: Compiler (Type checker) Version: 7.9
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC accepts invalid program Test Case: indexed-types/should_fail/T9433
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I was playing around with the following code, which tries to map a type family over a type (something I thought would not be allowed):

  , KindSignatures

type family Id x :: *
type instance Id a = a

type family Map (f :: * -> *) x :: *
type instance Map f [a] = [f a]

x :: Map Id [Bool]
x = []

Both GHC 7.8.3 and the current HEAD (7.9.20140811) accept this program! However, changing the definition of x to [True] gives an error:

    Couldn't match type ‘Id Bool’ with ‘Bool’
    Expected type: Map Id [Bool]
      Actual type: [Bool]
    In the expression: [True]
    In an equation for ‘x’: x = [True]

If I define y :: Id Bool with value True (which works fine) and define x = [y], I even get this error:

    Couldn't match type ‘Bool’ with ‘Id Bool’
    Expected type: Id Bool
      Actual type: Id Bool
    In the expression: y
    In the expression: [y]

Change History (5)

comment:1 Changed 5 years ago by Simon Peyton Jones <simonpj@…>

In 8ff4671422090acf9146e3a90dd38e2c6f72aebb/ghc:

Make Core Lint check for un-saturated type applications

Un-saturated type-family and type-synonym applications are
detected in the front end, but for some reason Lint wasn't
looking for them.

I came across this when wondering why Trac #9433 didn't give
a Core Lint error

comment:2 Changed 5 years ago by Simon Peyton Jones <simonpj@…>

In ee4501bbad6480509e8a60b5ff89c0b0b228b66d/ghc:

Check for un-saturated type family applications

This patch corrects an egregious error introduced by:

  commit 022f8750edf6f413fba31293435dcc62600eab77
  Author: Simon Peyton Jones <>
  Date:   Thu May 15 16:07:04 2014 +0100

    Refactoring around TyCon.isSynTyCon

    * Document isSynTyCon better
    * Add isTypeSyonymTyCon for regular H98 type synonyms
    * Use isTypeSynonymTyCon rather than isSynTyCon where
      the former is really intended

At this particular spot in TcValidity we really do mean
isSynTyCon and not isTypeSynonymTyCon.

Fixes Trac #9433

comment:3 Changed 5 years ago by simonpj

Status: newmerge
Test Case: indexed-types/should_fail/T9433

Thanks for reporting this.

Austin: worth merging ee4501 if we make 7.8.4


comment:4 Changed 5 years ago by rodlogic

Related ticket was closed as a duplicate: #9733 (may contain additional information that is relevant here).

comment:5 Changed 5 years ago by thoughtpolice

Milestone: 7.8.4
Resolution: fixed
Status: mergeclosed

Merged to ghc-7.8.

Note: See TracTickets for help on using tickets.