Created
October 10, 2014 18:04
-
-
Save jferris/2b77f459226560fc03a2 to your computer and use it in GitHub Desktop.
DOM Manipulation with ghcjs
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
module Main (main) where | |
import Control.Applicative ((<$>)) | |
import GHCJS.DOM (runWebGUI, webViewGetDomDocument) | |
import GHCJS.DOM.Document (documentGetBody, documentCreateElement) | |
import GHCJS.DOM.Types (castToHTMLDivElement) | |
import GHCJS.DOM.Node (nodeAppendChild) | |
import GHCJS.DOM.HTMLElement (htmlElementSetInnerText) | |
main :: IO () | |
main = do | |
runWebGUI $ \webView -> do | |
Just doc <- webViewGetDomDocument webView | |
Just body <- documentGetBody doc | |
Just div <- fmap castToHTMLDivElement <$> documentCreateElement doc "div" | |
htmlElementSetInnerText div "Hello, world!" | |
nodeAppendChild body $ Just div | |
return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment