[GHC] #15697: Typed holes inferring a more polymorphic type

GHC ghc-devs at haskell.org
Tue Oct 2 09:09:31 UTC 2018


#15697: Typed holes inferring a more polymorphic type
-------------------------------------+-------------------------------------
           Reporter:  sreenidhi      |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Compiler       |           Version:  8.6.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Consider these two snippets.

 {{{#!hs
 testFailure :: Char
 testFailure =
   let x = id _
   in  x
 }}}


 Suggestions provided were
 {{{
 /home/sreenidhi/Experiments/TypedHole.hs:3:14: error:
     • Found hole: _ :: a
       Where: ‘a’ is a rigid type variable bound by
                the inferred type of x :: a
                at /home/sreenidhi/Experiments/TypedHole.hs:3:7-14
     • In the first argument of ‘id’, namely ‘_’
       In the expression: id _
       In an equation for ‘x’: x = id _
     • Relevant bindings include
         x :: a (bound at /home/sreenidhi/Experiments/TypedHole.hs:3:7)
         testFailure :: Char
           (bound at /home/sreenidhi/Experiments/TypedHole.hs:2:1)

 }}}

 whereas for this one

 {{{#!hs
 testSuccess :: Char
 testSuccess = _
 }}}

 It correctly suggests

 {{{
 /home/sreenidhi/Experiments/TypedHole.hs:7:15: error:
     • Found hole: _ :: Char
     • In the expression: _
       In an equation for ‘testSuccess’: testSuccess = _
     • Relevant bindings include
         testSuccess :: Char
           (bound at /home/sreenidhi/Experiments/TypedHole.hs:7:1)
       Valid hole fits include
         testSuccess :: Char
           (bound at /home/sreenidhi/Experiments/TypedHole.hs:7:1)
         testFailure :: Char
           (defined at /home/sreenidhi/Experiments/TypedHole.hs:2:1)
         maxBound :: forall a. Bounded a => a
           with maxBound @Char
           (imported from ‘Prelude’ at
 /home/sreenidhi/Experiments/TypedHole.hs:1:1
            (and originally defined in ‘GHC.Enum’))
         minBound :: forall a. Bounded a => a
           with minBound @Char
           (imported from ‘Prelude’ at
 /home/sreenidhi/Experiments/TypedHole.hs:1:1
            (and originally defined in ‘GHC.Enum’))
 }}}

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


More information about the ghc-tickets mailing list