注意:因爲我的無線網卡在我的電腦上壞掉了,所以可能會出現一些拼寫錯誤(大寫字母等),所以我不能在這個電腦上安裝haskell,代碼(我沒有記憶棒XD)約束中含糊不清的類型變量`f0':Haskell
我一直在使用
Config line values 2 2
定義配置,但我只是不喜歡這個功能「開始」。凡是需要一個F - >˚F工作正常,但...
data Config = Config {
line :: Line,
nums :: [Nums],
indent :: Indent,
run :: Run
} deriving (Eq, Show)
class (Result f) => Test f where
start :: Line -> [Nums] -> f
instance Test Config where
start line nums = Config line nums 0 0
如果我運行
> start 2 [0,0,0]
應返回
> Config 2 [0,0,0] 0 0
我得到的錯誤:
Ambiguous type variable `f0' in the constraint:
(Test f0) arising from a use of `start'
Probable fix: add a type signature that fixes these type variable(s)
正在運行
> :t Config 2 [0,0,0] 0 0
給出
> Config 2 [0,0,0] 0 0 :: Config
這是正確的
你正在使用什麼'Test'類? –
你能告訴我們在什麼情況下你會得到錯誤嗎? –
如果我運行>開始2 [0,0,0,0] –