Re: [GHC] #13946: 自動選擇實例

GHC ghc-devs at haskell.org
Sun Jul 9 08:54:33 UTC 2017


#13946: 自動選擇實例
-------------------------------------+-------------------------------------
        Reporter:  zaoqi             |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.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:                    |
-------------------------------------+-------------------------------------
Description changed by zaoqi:

@@ -28,0 +28,1 @@
+

New description:

 {{{#!hs
 {-# LANGUAGE MultiParamTypeClasses #-}

 class B a b where
     b :: a -> b

 instance B Int Char where
     b = error "B Int Char"

 instance B Int () where
     b = error "B Int ()"
 }}}

 {{{
 *Main> :t (b undefined)::Char

 <interactive>:1:2: error:
     • Ambiguous type variable ‘a0’ arising from a use of ‘b’
       prevents the constraint ‘(B a0 Char)’ from being solved.
       Probable fix: use a type annotation to specify what ‘a0’ should be.
       These potential instance exist:
         instance [safe] B Int Char -- Defined at t.hs:6:10
     • In the expression: (b undefined) :: Char
 }}}
 怎麼讓GHC在這種情況下自動選擇任意一個實例

 [WARING]Google Translate

 How to make GHC automatically select any instance in this case

--

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


More information about the ghc-tickets mailing list