
#13946: 自動選擇實例 -------------------------------------+------------------------------------- Reporter: zaoqi | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 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: -------------------------------------+------------------------------------- {{{#!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 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler