[英]Get keyboard event in purescript
I want to get keydown event in purescript so I used DomEvent. 我想用purescript获取keydown事件,所以我使用了DomEvent。 Here is my code.
这是我的代码。
main :: Eff (HA.HalogenEffects (console :: CONSOLE, timer :: T.TIMER)) Unit
main = HA.runHalogenAff do
body <- HA.awaitBody
cube <- runUI C.cubes unit body
documenttarget <- liftEff $ window >>= document <#> DHT.htmlDocumentToEventTarget
addEventListener (EventType "keydown") (eventListener test) true (documenttarget)
H.liftEff $ T.setInterval (1000 / frameRate) do
HA.runHalogenAff $ cube.query $ H.action C.Tick
When I try to run this code, I am getting error like this. 当我尝试运行此代码时,出现这样的错误。
documenttarget <- liftEff $ window >>= document <#> DHT.htmlDocumentToEventTarget
Coudn't match type Eff with type Aff
I know aff and eff but I am new to purescript so I am not sure what I have to do to fix this issue. 我了解aff和eff,但是我是purescript的新手,所以我不确定要解决此问题需要做什么。 What can I do?
我能做什么?
The block that you pass to halogenRunAff
is an Aff
block, so every line in it must be an Aff
. 传递给
halogenRunAff
的块是一个Aff
块,因此其中的每一行都必须是一个Aff
。 But liftEff
returns an Eff
instead. 但是
liftEff
返回一个Eff
。 So there is a mismatch. 因此存在不匹配。
This is what the compiler is telling you: "can't match Eff with Aff". 这就是编译器告诉您的:“无法将Eff与Aff匹配”。
To fix this, replace liftEff
with liftAff
: 要解决此问题,请将
liftEff
替换为liftAff
:
documenttarget <- liftAff $ window >>= document <#> DHT.htmlDocumentToEventTarget
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.