Cabbage.hs:इस प्रकार परिवर्तनीय अस्पष्ट क्यों है?
Cabbage.hs:7:19:
Ambiguous type variable `a' in the constraint:
`Cabbage a' arising from a use of `foo' at Cabbage.hs:7:19-38
Probable fix: add a type signature that fixes these type variable(s)
मुझे समझ नहीं आता क्यों a
अस्पष्ट है:
module Cabbage where
class Cabbage a
where foo :: a -> String -- the parameter is only present for its type,
-- the parameter value will be ignored
bar :: String -> a
quux :: Cabbage a => String -> a
quux s = bar (s ++ foo (undefined :: a))
जब मैं (GHC) के साथ संकलन मैं यह त्रुटि संदेश मिलता है। निश्चित रूप से लाइन 7 में a
लाइन 6 में a
जैसा ही है? मैं यह कैसे तय करुं?
वैकल्पिक रूप से, प्रति-आवृत्ति निरंतर घोषित करने का एक बेहतर तरीका है?