我收到一个我不明白的错误。我正在使用的库具有以下功能:
getComputedStyle ::
(MonadIO m, IsElement element, ToJSString pseudoElement) =>
Window ->
Maybe element ->
Maybe pseudoElement -> m (Maybe CSSStyleDeclaration)
当我这样称呼时:
Window.getComputedStyle window (Just element) Nothing
我收到此错误:
Could not deduce (GHCJS.DOM.Types.ToJSString pseudoElement0)
arising from a use of ‘getComputedStyle’
from the context (Control.Monad.IO.Class.MonadIO m,
IsElement element)
bound by the inferred type of
isBold :: (Control.Monad.IO.Class.MonadIO m, IsElement element) =>
Window -> element -> m (Maybe CSSStyleDeclaration)
at src/Main.hs:(39,1)-(40,61)
The type variable ‘pseudoElement0’ is ambiguous
Note: there are several potential instances:
instance GHCJS.DOM.Types.ToJSString
ghcjs-base-0.2.0.0:Data.JSString.Internal.Type.JSString
-- Defined in ‘GHCJS.DOM.Types’
instance GHCJS.DOM.Types.ToJSString
ghcjs-base-0.2.0.0:Data.JSString.Internal.Type.JSString
-- Defined in ‘GHCJS.DOM.Types’
instance GHCJS.DOM.Types.ToJSString
text-1.2.1.1:Data.Text.Internal.Text
-- Defined in ‘GHCJS.DOM.Types’
instance GHCJS.DOM.Types.ToJSString [Char]
-- Defined in ‘GHCJS.DOM.Types’
...
为什么编译器关心类型?我传递了一个Nothing值,因此Just值的类型并不真正相关。