packages feed

ghcjs-dom-hello 3.0.0.0 → 4.0.0.0

raw patch · 2 files changed

+11/−7 lines, 2 filesdep ~ghcjs-dom

Dependency ranges changed: ghcjs-dom

Files

ghcjs-dom-hello.cabal view
@@ -1,5 +1,5 @@ name: ghcjs-dom-hello-version: 3.0.0.0+version: 4.0.0.0 cabal-version: >=1.6 build-type: Simple license: MIT@@ -26,6 +26,6 @@     build-depends:         mtl >=2.1 && <2.3,         base >=4.2 && <5,-        ghcjs-dom >=0.4 && <0.5+        ghcjs-dom >=0.5 && <0.6     hs-source-dirs: src 
src/Main.hs view
@@ -6,20 +6,24 @@ import Control.Concurrent.MVar (takeMVar, putMVar, newEmptyMVar)  import GHCJS.DOM (run, syncPoint, currentDocument)-import GHCJS.DOM.Document (getBody, createElement, createTextNode)+import GHCJS.DOM.Types+       (HTMLParagraphElement(..), HTMLSpanElement(..), unsafeCastTo)+import GHCJS.DOM.Document (getBodyUnsafe, createElementUnsafe, createTextNode) import GHCJS.DOM.Element (setInnerHTML) import GHCJS.DOM.Node (appendChild) import GHCJS.DOM.EventM (on, mouseClientXY) import qualified GHCJS.DOM.Document as D (click) import qualified GHCJS.DOM.Element as E (click) -main = run 3708 $ do+main = do+  putStrLn "<a href=\"http://localhost:3708/\">http://localhost:3708/</a>"+  run 3708 $ do     Just doc <- currentDocument-    Just body <- getBody doc+    body <- getBodyUnsafe doc     setInnerHTML body (Just "<h1>Kia ora (Hi)</h1>")     on doc D.click $ do         (x, y) <- mouseClientXY-        Just newParagraph <- createElement doc (Just "p")+        newParagraph <- createElementUnsafe doc (Just "p") >>= unsafeCastTo HTMLParagraphElement         text <- createTextNode doc $ "Click " ++ show (x, y)         appendChild newParagraph text         appendChild body (Just newParagraph)@@ -27,7 +31,7 @@      -- Make an exit button     exitMVar <- liftIO newEmptyMVar-    Just exit <- createElement doc (Just "span")+    exit <- createElementUnsafe doc (Just "span") >>= unsafeCastTo HTMLSpanElement     text <- createTextNode doc "Click here to exit"     appendChild exit text     appendChild body (Just exit)