1
我知道在某些情況下,我必須爲isString實例的某個東西提供類型註釋,但我不完全確定必須在什麼位置以及爲什麼必須這樣做。處理isString實例的類型註釋
我有一個我想與Bootstrap3渲染每following documentation
在我的表格形式,如果我只是把它作爲bootstrapSubmit "Register"
,我將會得到如下:
No instance for (Data.String.IsString msg0)
arising from the literal `"Register"'
The type variable `msg0' is ambiguous
如果我改變它到(bootstrapSubmit ("add" :: BootstrapSubmit Text))
,它編譯。爲什麼它不能像文檔顯示那樣對我有用?
下面是其他一些例子我感到困惑:
的bfs功能,我想用在我的表格如下:
areq intField (bfs "Weight") Nothing
讓我的字段,以獲取額外的form-control
類。與No instance for...
同樣的故事將其更改爲areq intField (bfs ("Weight"::Text)) Nothing
可修復類型問題。
爲什麼這不適用於沒有類型註釋的廣告?
您是否嘗試過在[Bootstrap3模塊(HTTP的頂部添加了'OverloadedStrings'編譯,如: //hackage.haskell.org/package/yesod-form-1.3.8.2/docs/src/Yesod-Form-Bootstrap3.html)? –
我只是試圖添加它,但它沒有幫助,同樣的錯誤。雖然OverloadedStrings在我的項目中幾乎處於活動狀態,但與TemplateHaskell和各種其他擴展一樣,我的印象還是很糟糕。 – rafalio