Ticket #2599 (closed feature request: invalid)

Opened 5 years ago

Last modified 2 years ago

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 Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

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

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 2 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 2 years ago by simonpj

  • status changed from new to closed
  • failure set to None/Unknown
  • resolution set to invalid

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.