0
我定義我的模型是Model = Dict Int String
然而,在編譯時使用詮釋或數字,我得到number
代替Int
所以它是錯誤的:在榆樹字典
The 2nd argument to function `get` is causing a mismatch.
71| Dict.get 3 model
^^^^^
Function `get` is expecting the 2nd argument to be:
Dict number v
But it is:
Model
,不幸的是榆樹REPL不返回Dict number
同樣的事情而不是Dict Int
。
> Dict.fromList [ (1, {a= 1})]
Dict.fromList [(1,{ a = 1 })] : Dict.Dict number { a : number1 }
某些語言如Haskell中暴露Int
作爲以及Integer
以及number
我怎麼能強迫它是整數?
我需要向下收縮我的代碼到SCCCE例如http://sscce.org –
上述答案的重要組成部分是,'貨號'被定義爲一個'Dict'別名。 請確保您的模型定義使用'alias'關鍵字。否則,您將您的模型定義爲單個案例區分聯盟。 'type alias Model = Dict Int String' – Adrian