以下代码会产生此错误:
module Broken1 where
import Control.Monad.Aff.Class (MonadAff)
import Control.Monad.Aff (Aff())
import DOM.HTML.Types
import Halogen
import DOM
import Control.Monad.Eff.Exception
import Control.Monad.Aff.AVar
import Prelude
import qualified Halogen.HTML.Indexed as H
data State = State
data Query a = Query a
ui :: forall eff g. (MonadAff (HalogenEffects eff) g) => Component State Query g
ui = component (\_ -> H.div_ []) (\(Query next) -> pure next)
main' :: forall eff a. (HTMLElement -> Aff (HalogenEffects eff) a)
-> Aff (HalogenEffects eff) Unit
main' addToDOM = do
{ node: node, driver: driver } <- runUI ui State
let driver' :: Natural Query (Aff (HalogenEffects eff))
driver' = driver
return unit
错误:
at Broken1.purs line 34, column 19 - line 36, column 5
Could not match type
a2
with type
a1
while trying to match type a2
with type a1
while checking that expression driver
has type Query a1 -> Aff ( avar :: AVAR
, err :: EXCEPTION
, dom :: DOM
| eff1
)
a1
in value declaration main'
如果省略driver'
的类型签名,则没有编译器错误,正如我所希望的那样。如果我问psc
签名(通过用_
替换类型),这是建议:
Wildcard type definition has the inferred type
forall a. Query a -> Aff ( dom :: DOM
, err :: EXCEPTION
, avar :: AVAR
| eff4
)
a
当我将其剪切并粘贴到代码中而不是原始类型时,错误与上面相同。
在第二种情况下,这实际上是有道理的,因为量词打开了一个新的范围,应该在主要的签名中捕获。但即使我删除forall a
,类型错误仍然存在。
garyb今天早些时候在#purescript上说它可能是类型检查器中的一个错误。无论如何我都会在这里张贴这个,直到确定事实为止。
谢谢! (: