Skip to content
  • Simon Peyton Jones's avatar
    Add type "holes", enabled by -XTypeHoles, Trac #5910 · 8a9a7a8c
    Simon Peyton Jones authored
    This single commit combines a lot of work done by
    Thijs Alkemade <thijsalkemade@gmail.com>, plus a slew
    of subsequent refactoring by Simon PJ.
    
    The basic idea is
    * Add a new expression form "_", a hole, standing for a not-yet-written expression
    * Give a useful error message that
       (a) gives the type of the hole
       (b) gives the types of some enclosing value bindings that
           mention the hole
    
    Driven by this goal I did a LOT of refactoring in TcErrors, which in turn
    allows us to report enclosing value bindings for other errors, not just
    holes.  (Thijs rightly did not attempt this!)
    
    The major data type change is a new form of constraint
      data Ct = ...
        	  | CHoleCan {
        	      cc_ev       :: CtEvidence,
        	      cc_hole_ty  :: TcTauType,
        	      cc_depth    :: SubGoalDepth }
    
    I'm still in two minds about whether this is the best plan. Another
    possibility would be to have a predicate type for holes, somthing like
       class Hole a where
         holeValue :: a
    
    It works the way it is, but there are some annoying special cases for
    CHoleCan (just grep for "CHoleCan").
    8a9a7a8c