[GHC] #9109: Improve error messages around "untouchable" type variables

GHC ghc-devs at haskell.org
Wed May 14 18:25:26 UTC 2014


#9109: Improve error messages around "untouchable" type variables
------------------------------------+-------------------------------------
       Reporter:  goldfire          |             Owner:
           Type:  bug               |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  Compiler          |           Version:  7.8.2
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:                    |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 When I say

 {{{
 {-# LANGUAGE GADTs #-}

 data G a where
   GBool :: G Bool

 foo GBool = True
 }}}

 I get

 {{{
     Couldn't match expected type ‘t’ with actual type ‘Bool’
       ‘t’ is untouchable
         inside the constraints (t1 ~ Bool)
         bound by a pattern with constructor
                    GBool :: G Bool,
                  in an equation for ‘foo’
         at /Users/rae/temp/Bug.hs:6:5-9
       ‘t’ is a rigid type variable bound by
           the inferred type of foo :: G t1 -> t at
 /Users/rae/temp/Bug.hs:6:1
     Relevant bindings include
       foo :: G t1 -> t (bound at /Users/rae/temp/Bug.hs:6:1)
     In the expression: True
     In an equation for ‘foo’: foo GBool = True
 }}}

 My code is indeed bogus and the error message is accurate. But, it's
 really unhelpful in that the solution to my problem is "add a type
 signature". In general, I occasionally see folks complain about
 "untouchable" error messages. Most recently, see
 [http://www.haskell.org/pipermail/glasgow-haskell-
 users/2014-May/024993.html this thread], which inspired this report.

 Is the solution ''always'' to just add a type signature/annotation? Would
 it make sense to include a link to a stable wiki page about just what
 "untouchable" variables are? I don't necessarily have a solution to this
 problem, but I think it's worth thinking about.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9109>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list