Opened 9 years ago

Closed 7 years ago

#2599 closed feature request (invalid)

Improve error message for type rigidity

Reported by: simonpj Owned by: simonpj
Priority: low Milestone: 7.0.2
Component: Compiler Version: 6.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

When saying that a GADT match is given a non-rigid type, we should be more explicit about where a type signature would help. For example, given the program:

data E x = E x

data Foo a where
  Foo :: Gadt a -> Foo a

data Gadt a where
  GadtValue :: a -> Gadt (E a)

g = case undefined of
        Foo GadtValue -> ()

I get the error message:

Test.hs:13:12:
    GADT pattern match with non-rigid result type `t'
      Solution: add a type signature
    In a case alternative: Foo GadtValue -> ()
    In the expression: case undefined of { Foo GadtValue -> () }
    In the definition of `g':
        g = case undefined of { Foo GadtValue -> () }

But where should the type signature be? A better hint would be:

Solution: add a type signature, probably at _TYPE_
(case undefined of { Foo GadtValue -> () }) :: _TYPE_

Similarly, we know when it's the scrutinee that needs a signature. And in a do-binding the "scrutinee" is really the right-hand side. We can get all this information from the matching context.

Change History (6)

comment:1 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:2 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:3 Changed 8 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:4 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:5 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:6 Changed 7 years ago by simonpj

Resolution: invalid
Status: newclosed
Type of failure: None/Unknown

The whole story about "rigidity" has changed, so I don't think this ticket makes sense any more.

Simon

Note: See TracTickets for help on using tickets.