Last active
August 29, 2015 14:09
-
-
Save Decoherence/2cd008b1a6ba453b437b to your computer and use it in GitHub Desktop.
Haskell: Compile to JavaScript -- handle onClick and onMouseOver events.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Haste | |
main :: IO () | |
main = do | |
-- Get handle to #msg div | |
msg <- elemById "msg" | |
case msg of | |
Just m -> do | |
-- Handle onClick event | |
onEvent m OnClick $ \_ _ -> do | |
setProp m "innerHTML" "Cool!" | |
setStyle m "fontSize" "30" | |
-- Handle onMouseOver event | |
onEvent m OnMouseOver $ \_ -> alert ("Sweet!") | |
_ -> error "Element not found" | |
return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment