Opened 9 years ago

Closed 9 years ago

#4099 closed bug (fixed)

Slighlty confusing error message with data families

Reported by: rl Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.13
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: indexed-types/should_fail/T4099
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Example code:

data family T a

foo :: T a -> a
foo (Just x) = x

Error message:

    Couldn't match expected type `T a' against inferred type `Maybe a1'
      NB: `T' is a type function
    In the pattern: Just x
    In the definition of `foo': foo (Just x) = x

Calling T a type function is confusing, I had to double check that I hadn't accidentally declared it as a type family. I would

  • call these things type families and data families in messages and
  • omit the message for data families altogether because it doesn't matter that T is one in this case.

Change History (1)

comment:1 Changed 9 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: indexed-types/should_fail/T4099

Yes good point. Fixed by

Mon May 31 15:04:13 BST 2010  simonpj@microsoft.com
  * Fix Trac #4099: better error message for type functions
  
  Now we only want about "T is a type function and might not be
  injective" when matchin (T x) against (T y), which is the case
  that is really confusing.

    M ./compiler/typecheck/TcTyFuns.lhs -14 +9
Note: See TracTickets for help on using tickets.