[GHC] #14824: automatically select instance

GHC ghc-devs at haskell.org
Tue Feb 27 11:30:29 UTC 2018


#14824: automatically select instance
-------------------------------------+-------------------------------------
        Reporter:  zaoqi             |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by AntC):

 See the Haskell 2010 Report section 4.3.4 **Ambiguous types, ...**

 The type for your expression `m [X1] :: forall a0. C X1 a0 => a0`. You've
 put the expression at the GHCi `*Main>` prompt, so there's an implicit
 `print` around it, which gives type

 {{{
 forall a0. (C X1 a0, Show a0) => String
 }}}

 Then type var `a0` is ambiguous in the sense in section 4.3.4. That's what
 the error message is saying.

 What type do you expect GHC to infer for `a0`? What are the rules of
 inference that will give that type? Please reference the Haskell 2010
 Report and/or GHC User Guide.

 Explain how the rules will work for expression `m [X0]` -- given the
 instances for class `C` as above.

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


More information about the ghc-tickets mailing list