Opened 8 years ago

Last modified 3 years ago

#1451 new feature request

Provide way to show the origin of a constraint

Reported by: iampure@… Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 6.6.1
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:


For a complex type (A b, C d, E e) => Something a b e -> Int, provide a way to given the query: where does A b come from? Respond with the line number of a function that causes that constraint. This should of course also work for non-Haskell 98 constraints.

This issue comes up when one by accident calls a function in the wrong layer of a monadic transformer stack.

Change History (6)

comment:1 Changed 8 years ago by simonpj

If you could give a concrete example of what you have in mind, it'd help. That is, exactly what do you want the programmer to be able to do or say? GHC does indeed report the origins for constraints in error messages, for example.


comment:2 Changed 8 years ago by iampure@…

Ok, given a complete module that compiles, I would ideally like to do ask where the constraint MonadState (A b) (ST s) for example is generated. Since there doesn't exist such an instance, it's a bug in my program, but GHC only starts to complain when I call a function that needs that instance, but pointing to the location of the call is of little use in this case. The information that it needs MonadState (A b) (ST s) typically comes from GHC itself already, but me tracking down where exactly it gets used in that way(e.g. where the call to put or get is) is still my job.

An IDE ideally would show in what layer of the monad transformer stack everything is executed, making finding such bugs trivial, instead of hard. Such an IDE will probably not exist for 20 years or it might not ever exist, but GHC providing such a feature would be a start.

comment:3 Changed 8 years ago by igloo

  • Component changed from Compiler to Compiler (Type checker)
  • Milestone set to _|_

It sounds hard have an interface for asking the question (perhaps it's not too bad inside ghci), hard to give the answer that the user is after, and would probably require significant changes to the typechecker, so I'm afraid I don't think we'll get to this any time soon.

comment:4 Changed 7 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:5 Changed 7 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple

comment:6 Changed 3 years ago by morabbin

  • Type of failure set to None/Unknown

Bump; still an interesting feature request?

Note: See TracTickets for help on using tickets.