I want to get keydown event in purescript so I used 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. What can I do?
The block that you pass to halogenRunAff is an Aff block, so every line in it must be an Aff. But liftEff returns an Eff instead. So there is a mismatch.
This is what the compiler is telling you: "can't match Eff with Aff".
To fix this, replace liftEff with liftAff:
documenttarget <- liftAff $ window >>= document <#> DHT.htmlDocumentToEventTarget
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With