From 117bf1c72d3f67285a6d3e51f61c686e103c2e33 Mon Sep 17 00:00:00 2001 From: Nickolay Kudasov Date: Fri, 26 Aug 2016 00:32:54 +0300 Subject: [PATCH 1/6] Fix errors and most warnings for PureScript 0.9.2 --- bower.json | 21 ++++++++----------- package.json | 22 -------------------- src/.webpack.js | 1 + src/Data/DOM/Simple/Ajax.purs | 6 +++--- src/Data/DOM/Simple/Document.purs | 6 +++--- src/Data/DOM/Simple/Element.purs | 10 ++++----- src/Data/DOM/Simple/Encode.purs | 5 ++--- src/Data/DOM/Simple/Events.purs | 25 +++++++++++------------ src/Data/DOM/Simple/NodeList.purs | 4 ++-- src/Data/DOM/Simple/Types.purs | 2 -- src/Data/DOM/Simple/Unsafe/Ajax.purs | 4 ++-- src/Data/DOM/Simple/Unsafe/Document.purs | 9 ++++---- src/Data/DOM/Simple/Unsafe/Element.purs | 10 ++++----- src/Data/DOM/Simple/Unsafe/Events.purs | 8 ++++---- src/Data/DOM/Simple/Unsafe/Navigator.purs | 6 +++--- src/Data/DOM/Simple/Unsafe/NodeList.purs | 9 ++++---- src/Data/DOM/Simple/Unsafe/Utils.purs | 1 + src/Data/DOM/Simple/Window.purs | 4 ++-- 18 files changed, 62 insertions(+), 91 deletions(-) delete mode 100644 package.json create mode 100644 src/.webpack.js diff --git a/bower.json b/bower.json index f526159..9328731 100644 --- a/bower.json +++ b/bower.json @@ -18,19 +18,16 @@ ], "main": [], "dependencies": { - "purescript-dom": "^0.2.8", - "purescript-arrays": "^0.4.3", - "purescript-maybe": "^0.3.4", - "purescript-foldable-traversable": "^0.4.1", - "purescript-tuples": "^0.4.0", - "purescript-strings": "^0.7.0", - "purescript-sets": "^0.5.2" + "purescript-dom": "^2.0.1", + "purescript-arrays": "^1.1.0", + "purescript-maybe": "^1.0.0", + "purescript-foldable-traversable": "^1.0.0", + "purescript-tuples": "^1.0.0", + "purescript-strings": "^1.1.0", + "purescript-sets": "^1.0.0" }, "devDependencies": { - "purescript-math": "^0.2.0", - "purescript-quickcheck": "^0.6.0" - }, - "resolutions": { - "purescript-strings": "^0.7.0" + "purescript-math": "*", + "purescript-quickcheck": "*" } } diff --git a/package.json b/package.json deleted file mode 100644 index cf76b33..0000000 --- a/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "purescript-simple-dom", - "version": "0.1.0", - "description": "learning", - "main": "", - "private": true, - "author": "Ashley Towns", - "license": "MIT", - "dependencies": { - "gulp": "^3.8.11", - "gulp-jscs": "^1.6.0", - "gulp-jshint": "^1.10.0", - "gulp-plumber": "^1.0.0", - "gulp-purescript": "^0.5.0-rc.1", - "gulp-run": "^1.6.8", - "rimraf": "^2.3.3" - }, - "devDependencies": { - "contextify": "https://github.com/brianmcd/contextify.git#9882e71", - "zombie": "^2.5.1" - } -} diff --git a/src/.webpack.js b/src/.webpack.js new file mode 100644 index 0000000..2bac876 --- /dev/null +++ b/src/.webpack.js @@ -0,0 +1 @@ +require('./Main.purs').main(); diff --git a/src/Data/DOM/Simple/Ajax.purs b/src/Data/DOM/Simple/Ajax.purs index 72a3d69..6a69753 100644 --- a/src/Data/DOM/Simple/Ajax.purs +++ b/src/Data/DOM/Simple/Ajax.purs @@ -28,7 +28,7 @@ module Data.DOM.Simple.Ajax import Prelude import Control.Monad.Eff -import Data.Function +import Data.Function.Uncurried import Data.Maybe (Maybe(..)) import DOM @@ -92,7 +92,7 @@ foreign import makeXMLHttpRequest :: forall eff. (Eff (dom :: DOM | eff) XMLHttp readyState :: forall eff. XMLHttpRequest -> Eff (dom :: DOM | eff) ReadyState readyState x = do r <- unsafeReadyState x - return $ case r of + pure $ case r of 0 -> Unsent 1 -> Opened 2 -> HeadersReceived @@ -122,7 +122,7 @@ setResponseType rt x = runFn2 unsafeSetResponseType x (show rt) responseType :: forall eff. XMLHttpRequest -> Eff (dom :: DOM | eff) ResponseType responseType obj = do r <- unsafeResponseType obj - return $ case r of + pure $ case r of "arraybuffer" -> ArrayBuffer "blob" -> Blob "document" -> Document diff --git a/src/Data/DOM/Simple/Document.purs b/src/Data/DOM/Simple/Document.purs index 5f3970f..2785200 100644 --- a/src/Data/DOM/Simple/Document.purs +++ b/src/Data/DOM/Simple/Document.purs @@ -21,10 +21,10 @@ class Document b where createElement :: forall eff. String -> b -> (Eff (dom :: DOM | eff) HTMLElement) instance htmlDocumentElement :: Element HTMLDocument where - getElementById id el = (unsafeGetElementById id el) >>= (return <<< ensure) + getElementById id el = (unsafeGetElementById id el) >>= (pure <<< ensure) getElementsByClassName = unsafeGetElementsByClassName getElementsByName = unsafeGetElementsByName - querySelector sel el = (unsafeQuerySelector sel el) >>= (return <<< ensure) + querySelector sel el = (unsafeQuerySelector sel el) >>= (pure <<< ensure) querySelectorAll = unsafeQuerySelectorAll getAttribute = unsafeGetAttribute setAttribute = unsafeSetAttribute @@ -45,7 +45,7 @@ instance htmlDocumentElement :: Element HTMLDocument where classAdd = unsafeClassAdd classToggle = unsafeClassToggle classContains = unsafeClassContains - offsetParent el = (unsafeOffsetParent el) >>= (ensure >>> return) + offsetParent el = (unsafeOffsetParent el) >>= (ensure >>> pure) offsetHeight = unsafeOffsetHeight offsetWidth = unsafeOffsetWidth offsetTop = unsafeOffsetTop diff --git a/src/Data/DOM/Simple/Element.purs b/src/Data/DOM/Simple/Element.purs index 5cfc675..df403c9 100644 --- a/src/Data/DOM/Simple/Element.purs +++ b/src/Data/DOM/Simple/Element.purs @@ -12,8 +12,8 @@ import Data.DOM.Simple.Types import Data.Foldable(for_) import Data.Maybe -import qualified Data.Array as A -import qualified Data.Tuple as T +import Data.Array as A +import Data.Tuple as T class Element b where getElementById :: forall eff. String -> b -> (Eff (dom :: DOM | eff) (Maybe HTMLElement)) @@ -47,10 +47,10 @@ class Element b where offsetLeft :: forall eff. b -> (Eff (dom :: DOM | eff) Int) instance htmlElement :: Element HTMLElement where - getElementById id el = (unsafeGetElementById id el) >>= (ensure >>> return) + getElementById id el = (unsafeGetElementById id el) >>= (ensure >>> pure) getElementsByClassName = unsafeGetElementsByClassName getElementsByName = unsafeGetElementsByName - querySelector sel el = (unsafeQuerySelector sel el) >>= (ensure >>> return) + querySelector sel el = (unsafeQuerySelector sel el) >>= (ensure >>> pure) querySelectorAll = unsafeQuerySelectorAll getAttribute = unsafeGetAttribute setAttribute = unsafeSetAttribute @@ -71,7 +71,7 @@ instance htmlElement :: Element HTMLElement where classAdd = unsafeClassAdd classToggle = unsafeClassToggle classContains = unsafeClassContains - offsetParent el = (unsafeOffsetParent el) >>= (ensure >>> return) + offsetParent el = (unsafeOffsetParent el) >>= (ensure >>> pure) offsetHeight = unsafeOffsetHeight offsetWidth = unsafeOffsetWidth offsetTop = unsafeOffsetTop diff --git a/src/Data/DOM/Simple/Encode.purs b/src/Data/DOM/Simple/Encode.purs index 8470a25..6c149b8 100644 --- a/src/Data/DOM/Simple/Encode.purs +++ b/src/Data/DOM/Simple/Encode.purs @@ -1,8 +1,7 @@ module Data.DOM.Simple.Encode where -import DOM -import Control.Monad.Eff -import Data.DOM.Simple.Types +import DOM (DOM) +import Control.Monad.Eff (Eff) foreign import encodeURIComponent :: String -> String foreign import decodeURIComponent :: String -> String diff --git a/src/Data/DOM/Simple/Events.purs b/src/Data/DOM/Simple/Events.purs index d5611f5..7668c38 100644 --- a/src/Data/DOM/Simple/Events.purs +++ b/src/Data/DOM/Simple/Events.purs @@ -1,17 +1,15 @@ module Data.DOM.Simple.Events where -import Prelude +import Prelude (class Show, Unit, show, (<$>), (<>), (>>>)) +import Partial.Unsafe (unsafePartial) -import Control.Monad.Eff -import Control.Monad +import Control.Monad.Eff (Eff) -import Data.DOM.Simple.Types -import Data.DOM.Simple.Window(document, globalWindow) -import Data.DOM.Simple.Ajax +import Data.DOM.Simple.Types (XMLHttpRequest, DOMEvent, HTMLWindow) import Data.DOM.Simple.Unsafe.Events -import Data.DOM.Simple.Unsafe.Element -import Data.DOM.Simple.Document -import DOM +import Data.DOM.Simple.Unsafe.Element (HTMLElement) +import Data.DOM.Simple.Document (HTMLDocument) +import DOM (DOM) -- XXX Should this be in the Prelude? class Read s where @@ -46,7 +44,7 @@ instance mouseEventTypeShow :: Show MouseEventType where show MouseDblClickEvent = "dblclick" show MouseUpEvent = "mouseup" show MouseDownEvent = "mousedown" - show (MouseUnknownEvent x) = "unknown event: " ++ x + show (MouseUnknownEvent x) = "unknown event: " <> x instance mouseEventTypeRead :: Read MouseEventType where read "mousemove" = MouseMoveEvent @@ -108,7 +106,7 @@ instance keyboardEventTypeShow :: Show KeyboardEventType where show KeydownEvent = "keydown" show KeypressEvent = "keypress" show KeyupEvent = "keyup" - show (KeyUnknownEvent x) = "unknown key event:" ++ x + show (KeyUnknownEvent x) = "unknown key event:" <> x instance keyboardEventTypeRead :: Read KeyboardEventType where read "keydown" = KeydownEvent @@ -193,7 +191,7 @@ instance uiEventTypeShow :: Show UIEventType where show SelectEvent = "select" show ResizeEvent = "resize" show ScrollEvent = "scroll" - show (UnknownEvent x) = "unknown uievent:" ++ x + show (UnknownEvent x) = "unknown uievent:" <> x instance uiEventTypeRead :: Read UIEventType where read "load" = LoadEvent @@ -248,6 +246,7 @@ instance showProgressEventType :: Show ProgressEventType where show ProgressProgressEvent = "progress" show ProgressTimeoutEvent = "timeout" +readProgressEventType :: (Partial) => String -> ProgressEventType readProgressEventType "abort" = ProgressAbortEvent readProgressEventType "error" = ProgressErrorEvent readProgressEventType "load" = ProgressLoadEvent @@ -263,7 +262,7 @@ class (Event e) <= ProgressEvent e where total :: forall eff. e -> (Eff (dom :: DOM | eff) Number) instance progressEventDOMEvent :: ProgressEvent DOMEvent where - progressEventType ev = readProgressEventType <$> unsafeEventProp "type" ev + progressEventType ev = unsafePartial readProgressEventType <$> unsafeEventProp "type" ev lengthComputable = unsafeEventProp "lengthComputable" loaded = unsafeEventProp "loaded" total = unsafeEventProp "total" diff --git a/src/Data/DOM/Simple/NodeList.purs b/src/Data/DOM/Simple/NodeList.purs index 9cad58f..350b43c 100644 --- a/src/Data/DOM/Simple/NodeList.purs +++ b/src/Data/DOM/Simple/NodeList.purs @@ -21,13 +21,13 @@ class NodeListInst b where instance nodeList :: NodeListInst NodeList where length = unsafeNodeListLength - item idx el = (unsafeNodeListItem idx el) >>= (ensure >>> return) + item idx el = (unsafeNodeListItem idx el) >>= (ensure >>> pure) nodeListToArray :: forall eff. NodeList -> (Eff (dom :: DOM | eff) (Array HTMLElement)) nodeListToArray nl = do len <- length nl xs <- sequence (map (\i -> item i nl) $ range 0 len) - return $ catMaybes xs + pure $ catMaybes xs nodeListToArray' :: forall eff. NodeList -> (Eff (dom :: DOM | eff) (Array HTMLElement)) nodeListToArray' = unsafeNodeListToArray diff --git a/src/Data/DOM/Simple/Types.purs b/src/Data/DOM/Simple/Types.purs index 3b53b12..f05a065 100644 --- a/src/Data/DOM/Simple/Types.purs +++ b/src/Data/DOM/Simple/Types.purs @@ -1,7 +1,5 @@ module Data.DOM.Simple.Types where -import Control.Monad.Eff - foreign import data HTMLWindow :: * foreign import data XMLHttpRequest :: * foreign import data DOMNavigator :: * diff --git a/src/Data/DOM/Simple/Unsafe/Ajax.purs b/src/Data/DOM/Simple/Unsafe/Ajax.purs index d632955..efeddac 100644 --- a/src/Data/DOM/Simple/Unsafe/Ajax.purs +++ b/src/Data/DOM/Simple/Unsafe/Ajax.purs @@ -4,7 +4,7 @@ import Prelude import DOM import Control.Monad.Eff -import Data.Function +import Data.Function.Uncurried import Data.DOM.Simple.Types @@ -24,4 +24,4 @@ foreign import unsafeResponseType :: forall eff. XMLHttpRequest -> Eff (dom :: D foreign import unsafeResponse :: forall eff a. XMLHttpRequest -> Eff (dom :: DOM | eff) a -foreign import unsafeGetResponseHeader :: forall eff a. Fn2 XMLHttpRequest String (Eff (dom :: DOM | eff) String) +foreign import unsafeGetResponseHeader :: forall eff. Fn2 XMLHttpRequest String (Eff (dom :: DOM | eff) String) diff --git a/src/Data/DOM/Simple/Unsafe/Document.purs b/src/Data/DOM/Simple/Unsafe/Document.purs index a1021ec..3174f36 100644 --- a/src/Data/DOM/Simple/Unsafe/Document.purs +++ b/src/Data/DOM/Simple/Unsafe/Document.purs @@ -1,12 +1,11 @@ module Data.DOM.Simple.Unsafe.Document where -import Prelude +import Prelude (Unit) -import DOM -import Control.Monad.Eff +import DOM (DOM) +import Control.Monad.Eff (Eff) -import Data.DOM.Simple.Types -import Data.DOM.Simple.Unsafe.Element +import Data.DOM.Simple.Unsafe.Element (HTMLElement) foreign import unsafeTitle :: forall eff a. a -> (Eff (dom :: DOM | eff) String) diff --git a/src/Data/DOM/Simple/Unsafe/Element.purs b/src/Data/DOM/Simple/Unsafe/Element.purs index a15586e..2a94e63 100644 --- a/src/Data/DOM/Simple/Unsafe/Element.purs +++ b/src/Data/DOM/Simple/Unsafe/Element.purs @@ -1,13 +1,13 @@ module Data.DOM.Simple.Unsafe.Element where -import Prelude +import Prelude (class Show, Unit) -import DOM -import DOM.Node.Types +import DOM (DOM) +import DOM.Node.Types (NodeList) -import Control.Monad.Eff +import Control.Monad.Eff (Eff) -import Data.DOM.Simple.Types +import Data.DOM.Simple.Types (HTMLWindow) import Data.DOM.Simple.Unsafe.Utils(showImpl) foreign import data HTMLElement :: * diff --git a/src/Data/DOM/Simple/Unsafe/Events.purs b/src/Data/DOM/Simple/Unsafe/Events.purs index 2eac4df..411aeaf 100644 --- a/src/Data/DOM/Simple/Unsafe/Events.purs +++ b/src/Data/DOM/Simple/Unsafe/Events.purs @@ -1,11 +1,11 @@ module Data.DOM.Simple.Unsafe.Events where -import Prelude +import Prelude (Unit) -import DOM -import Control.Monad.Eff +import DOM (DOM) +import Control.Monad.Eff (Eff) -import Data.DOM.Simple.Types +import Data.DOM.Simple.Types (DOMEvent, HTMLWindow) foreign import unsafeAddEventListener :: forall eff t e b. String -> (e -> Eff (dom :: DOM | t) Unit) -> b -> (Eff (dom :: DOM | eff) Unit) diff --git a/src/Data/DOM/Simple/Unsafe/Navigator.purs b/src/Data/DOM/Simple/Unsafe/Navigator.purs index f835019..fdf55fb 100644 --- a/src/Data/DOM/Simple/Unsafe/Navigator.purs +++ b/src/Data/DOM/Simple/Unsafe/Navigator.purs @@ -1,9 +1,9 @@ module Data.DOM.Simple.Unsafe.Navigator where -import DOM -import Control.Monad.Eff +import DOM (DOM) +import Control.Monad.Eff (Eff) -import Data.DOM.Simple.Types +import Data.DOM.Simple.Types (DOMNavigator) foreign import unsafeAppName ::forall eff. DOMNavigator -> Eff (dom :: DOM | eff) String diff --git a/src/Data/DOM/Simple/Unsafe/NodeList.purs b/src/Data/DOM/Simple/Unsafe/NodeList.purs index 8a785ba..fa88791 100644 --- a/src/Data/DOM/Simple/Unsafe/NodeList.purs +++ b/src/Data/DOM/Simple/Unsafe/NodeList.purs @@ -1,11 +1,10 @@ module Data.DOM.Simple.Unsafe.NodeList where -import DOM -import DOM.Node.Types -import Control.Monad.Eff +import DOM (DOM) +import DOM.Node.Types (NodeList) +import Control.Monad.Eff (Eff) -import Data.DOM.Simple.Types -import Data.DOM.Simple.Unsafe.Element +import Data.DOM.Simple.Unsafe.Element (HTMLElement) foreign import unsafeNodeListLength :: forall eff. NodeList -> Eff (dom :: DOM | eff) Int diff --git a/src/Data/DOM/Simple/Unsafe/Utils.purs b/src/Data/DOM/Simple/Unsafe/Utils.purs index f3a57d5..d78b372 100644 --- a/src/Data/DOM/Simple/Unsafe/Utils.purs +++ b/src/Data/DOM/Simple/Unsafe/Utils.purs @@ -4,6 +4,7 @@ import Data.Maybe foreign import ensure3 :: forall a. Maybe a -> (a -> Maybe a) -> a -> Maybe a +ensure :: forall a. a -> Maybe a ensure = ensure3 Nothing Just foreign import showImpl :: forall a. a -> String diff --git a/src/Data/DOM/Simple/Window.purs b/src/Data/DOM/Simple/Window.purs index 5746c77..aab427f 100644 --- a/src/Data/DOM/Simple/Window.purs +++ b/src/Data/DOM/Simple/Window.purs @@ -10,8 +10,8 @@ import Data.DOM.Simple.Unsafe.Window import Data.DOM.Simple.Document import Data.Maybe -import qualified Data.Array as Array -import qualified Data.String as String +import Data.Array as Array +import Data.String as String class Location b where getLocation :: forall eff. b -> (Eff (dom :: DOM | eff) String) From 5f4e16b6477e1bac3c681f342997673c9b3efe99 Mon Sep 17 00:00:00 2001 From: Nickolay Kudasov Date: Fri, 26 Aug 2016 01:50:47 +0300 Subject: [PATCH 2/6] Rewrite tests with purescript-spec --- bower.json | 3 +- tests/Tests.js => test/Test.js | 2 +- test/Test.purs | 178 +++++++++++++++++++++++++++++++++ {tests => test}/test.html | 0 tests/Tests.purs | 176 -------------------------------- 5 files changed, 181 insertions(+), 178 deletions(-) rename tests/Tests.js => test/Test.js (88%) create mode 100644 test/Test.purs rename {tests => test}/test.html (100%) delete mode 100644 tests/Tests.purs diff --git a/bower.json b/bower.json index 9328731..b3955e5 100644 --- a/bower.json +++ b/bower.json @@ -28,6 +28,7 @@ }, "devDependencies": { "purescript-math": "*", - "purescript-quickcheck": "*" + "purescript-spec": "^0.8.0", + "purescript-aff": "*" } } diff --git a/tests/Tests.js b/test/Test.js similarity index 88% rename from tests/Tests.js rename to test/Test.js index 54349cb..8ea3459 100644 --- a/tests/Tests.js +++ b/test/Test.js @@ -1,7 +1,7 @@ /* global exports */ "use strict"; -// module Main +// module Test.Main exports.inspect = function (msg) { console.log(msg); diff --git a/test/Test.purs b/test/Test.purs new file mode 100644 index 0000000..53067fd --- /dev/null +++ b/test/Test.purs @@ -0,0 +1,178 @@ +module Test.Main where + +import Prelude (Unit, bind, (==), ($), (>>=)) + +import Data.Array (length) +import Data.Maybe (Maybe(..), isNothing) + +import Control.Monad.Eff.Class (liftEff) + +import Data.DOM.Simple.Element +import Data.DOM.Simple.Document (body, title, setTitle) +import Data.DOM.Simple.Window (globalWindow, navigator, document) +import Data.DOM.Simple.Navigator (language, appVersion, appName) +import Data.DOM.Simple.NodeList as NL + +import Test.Spec (describe, it) +import Test.Spec.Runner (run) +import Test.Spec.Assertions (shouldEqual) +import Test.Spec.Reporter.Console (consoleReporter) + +foreign import inspect :: forall a. a -> Unit + +foreign import tagname :: forall a. a -> String + +main = run [consoleReporter] do + describe "purescript-simple-dom" do + describe "document" do + it "Able to get the title of a document" do + doc <- liftEff (document globalWindow) + docTitle <- liftEff (title doc) + docTitle `shouldEqual` "testTitle" + it "Able to set the title of a document" do + docTitle <- liftEff do + doc <- document globalWindow + setTitle "modifiedTitle" doc + title doc + docTitle `shouldEqual` "modifiedTitle" + + describe "body" do + it "Able to get the body element of a document" do + docBody <- liftEff do + doc <- document globalWindow + body doc + tagname docBody `shouldEqual` "BODY" + it "Able to append a child" do + liftEff do + doc <- document globalWindow + docBody <- body doc + Just testDiv <- getElementById "test1" doc + appendChild docBody testDiv + + describe "elements" do + it "Able to look up element by id" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (getElementById "test1" doc) + tagname testDiv `shouldEqual` "DIV" + content <- liftEff (textContent testDiv) + content `shouldEqual` "testContent1" + it "Able to look up element by class name" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (querySelector ".test2" doc) + tagname testDiv `shouldEqual` "DIV" + content <- liftEff (textContent testDiv) + content `shouldEqual` "testContent2" + it "Able to look up element by tag name" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (querySelector "test3" doc) + tagname testDiv `shouldEqual` "DIV" + content <- liftEff (textContent testDiv) + content `shouldEqual` "testContent3" + it "Able to count items in a nodelist" do + doc <- liftEff (document globalWindow) + n <- liftEff do + testDivs <- querySelectorAll "div" doc + NL.length testDivs + n `shouldEqual` 2 + it "Able to retrieve an item from a nodelist" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff do + testDivs <- querySelectorAll "div" doc + NL.item 0 testDivs + tagname testDiv `shouldEqual` "DIV" + it "Able to convert a nodelist into an array" do + doc <- liftEff (document globalWindow) + testDivs <- liftEff (querySelectorAll "div" doc) + nl1 <- liftEff (NL.nodeListToArray testDivs) + nl2 <- liftEff (NL.nodeListToArray' testDivs) + length nl1 `shouldEqual` length nl2 + + describe "element modification" do + it "Able to modify input's value" do + doc <- liftEff (document globalWindow) + Just testInput <- liftEff (getElementById "input1" doc) + liftEff (setValue "foo bar baz" testInput) + val <- liftEff (value testInput) + val `shouldEqual` "foo bar baz" + it "Able to modify element's content" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (getElementById "test1" doc) + liftEff (setTextContent "Hello" testDiv) + content <- liftEff (textContent testDiv) + content `shouldEqual` "Hello" + it "Able to set an attribute on an element" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (getElementById "test1" doc) + testDivAttribute <- liftEff do + setAttribute "data-test" "hello" testDiv + getAttribute "data-test" testDiv + testDivAttribute `shouldEqual` "hello" + it "Able to remove an attribute from an element" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (getElementById "test1" doc) + testDivHasAttribute <- liftEff (hasAttribute "data-test" testDiv) + testDivHasAttribute `shouldEqual` true + liftEff (removeAttribute "data-test" testDiv) + testDivHasAttribute' <- liftEff (hasAttribute "data-test" testDiv) + testDivHasAttribute' `shouldEqual` false + it "Able to set a style attribute on an element" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (getElementById "test1" doc) + liftEff (setStyleAttr "color" "red" testDiv) + testDivStyleAttr <- liftEff (getStyleAttr "color" testDiv) + testDivStyleAttr `shouldEqual` "red" + + describe "navigator" do + it "Able to receive the appName from navigator" do + navigator <- liftEff (navigator globalWindow) + name <- liftEff (appName navigator) + name `shouldEqual` "Node.js jsDom" + it "Able to receive the appVersion from navigator" do + navigator <- liftEff (navigator globalWindow) + ver <- liftEff (appVersion navigator) + ver `shouldEqual` "Node.js jsDom" + it "Able to receive the language from navigator" do + navigator <- liftEff (navigator globalWindow) + lang <- liftEff (language navigator) + lang `shouldEqual` "en-US" + + -- Tests for offset* properties of an element. These behave strangely + -- with Zombie.js, so these tests just ensure that a value is returned. + describe "offset" do + it "Able to get the offsetParent of an element" do + -- HTMLElement.offsetParent is "undefined" in Zombie.js + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (getElementById "test1" doc) + noParent <- liftEff (offsetParent testDiv) + isNothing noParent `shouldEqual` true + it "Able to get the offsetHeight of an element" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (getElementById "test1" doc) + heightVal <- liftEff (offsetHeight testDiv) + heightVal `shouldEqual` 0 + it "Able to get the offsetWidth of an element" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (getElementById "test1" doc) + widthVal <- liftEff (offsetWidth testDiv) + widthVal `shouldEqual` 0 + it "Able to get the offsetTop of an element" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (getElementById "test1" doc) + topVal <- liftEff (offsetTop testDiv) + topVal `shouldEqual` 0 + it "Able to get the offsetLeft of an element" do + doc <- liftEff (document globalWindow) + Just testDiv <- liftEff (getElementById "test1" doc) + leftVal <- liftEff (offsetLeft testDiv) + leftVal `shouldEqual` 0 + + -- Unavailable in Zombie + {- + it "Able to add a class" do + hasTestClass <- classContains "testClass" testDiv + hasTestClass `shouldEqual` false + + classAdd "testClass" testDiv + hasTestClass' <- classContains "testClass" testDiv + hasTestClass' `shouldEqual` true + -} diff --git a/tests/test.html b/test/test.html similarity index 100% rename from tests/test.html rename to test/test.html diff --git a/tests/Tests.purs b/tests/Tests.purs deleted file mode 100644 index 586b9da..0000000 --- a/tests/Tests.purs +++ /dev/null @@ -1,176 +0,0 @@ -module Main where - -import Prelude - -import Data.Array -import Data.Maybe - -import Control.Monad.Eff -import Control.Monad.Eff.Console - -import Data.DOM.Simple.Unsafe.Element(HTMLElement(..)) -import Data.DOM.Simple.Types -import Data.DOM.Simple.Element -import Data.DOM.Simple.Document -import Data.DOM.Simple.Window -import Data.DOM.Simple.Encode -import Data.DOM.Simple.Ajax -import Data.DOM.Simple.Events -import Data.DOM.Simple.Navigator -import qualified Data.DOM.Simple.NodeList as NL - -import Test.QuickCheck - -foreign import inspect :: forall a. a -> Unit - -foreign import tagname :: forall a. a -> String - -checkTagName shouldBe element = do - let name = tagname element - quickCheck' 1 $ name == shouldBe - -checkContents shouldBe element = do - contents <- textContent (element :: HTMLElement) - quickCheck' 1 $ contents == shouldBe - -checkValue shouldBe element = do - val <- value (element :: HTMLElement) - quickCheck' 1 $ val == shouldBe - -main = do - doc <- document globalWindow - - log "Able to get the title of a document" - - docTitle <- title doc - quickCheck' 1 $ docTitle == "testTitle" - - -- attrib <- "#testDiv1" `getAttribute` "hello" - - log "Able to set the title of a document" - - setTitle "modifiedTitle" doc - docTitle1 <- title doc - - quickCheck' 1 $ docTitle1 == "modifiedTitle" - - - log "Able to get the body element of a document" - - docBody <- body doc - - checkTagName "BODY" docBody - - log "Able to look up elements" - - Just testDiv1 <- getElementById "test1" doc - - checkTagName "DIV" testDiv1 - checkContents "testContent1" testDiv1 - - Just testDiv2 <- querySelector ".test2" doc - - checkTagName "DIV" testDiv2 - checkContents "testContent2" testDiv2 - - Just testDiv3 <- querySelector "test3" doc - - checkTagName "TEST3" testDiv3 - checkContents "testContent3" testDiv3 - - testDivs <- querySelectorAll "div" doc - - log "Able to count items in a nodelist" - NL.length testDivs >>= (\len -> quickCheck' 1 $ len == 2) - - log "Able to retrieve an item from a nodelist" - Just testDiv4 <- NL.item 0 testDivs - checkTagName "DIV" testDiv4 - - log "Able to convert a nodelist into an array" - nl1 <- NL.nodeListToArray testDivs - nl2 <- NL.nodeListToArray' testDivs - quickCheck' 1 $ length nl1 == length nl2 - - log "Able to modify an elements contents" - - setTextContent "Hello" testDiv1 - - checkContents "Hello" testDiv1 - - - log "Able to modify a form element's value" - - Just testInput1 <- getElementById "input1" doc - - setValue "foo bar baz" testInput1 - - checkValue "foo bar baz" testInput1 - - log "Able to set an attribute on an element" - - setAttribute "data-test" "hello" testDiv1 - testDiv1Attribute <- getAttribute "data-test" testDiv1 - - quickCheck' 1 $ testDiv1Attribute == "hello" - - - log "Able to remove an attribute from an element" - - testDiv1HasAttribute <- hasAttribute "data-test" testDiv1 - quickCheck' 1 $ testDiv1HasAttribute == true - removeAttribute "data-test" testDiv1 - testDiv1HasAttribute' <- hasAttribute "data-test" testDiv1 - quickCheck' 1 $ testDiv1HasAttribute' == false - - log "Able to set a style attribute on an element" - - setStyleAttr "color" "red" testDiv1 - testDiv1StyleAttr <- getStyleAttr "color" testDiv1 - - quickCheck' 1 $ testDiv1StyleAttr == "red" - - navigator <- navigator globalWindow - log "Able to receive the appName from navigator" - appName navigator >>= (\name -> quickCheck' 1 $ name == "Node.js jsDom") - log "Able to receive the appVersion from navigator" - appVersion navigator >>= (\name -> quickCheck' 1 $ name == "Node.js jsDom") - log "Able to receive the language from navigator" - language navigator >>= (\name -> quickCheck' 1 $ name == "en-US") - - log "Able to append a child" - appendChild docBody testDiv1 - - -- Tests for offset* properties of an element. These behave strangely - -- with Zombie.js, so these tests just ensure that a value is returned. - - log "Able to get the offsetParent of an element" - -- HTMLElement.offsetParent is "undefined" in Zombie.js - noParent <- offsetParent testDiv1 - quickCheck' 1 $ isNothing noParent - - log "Able to get the offsetHeight of an element" - heightVal <- offsetHeight testDiv1 - quickCheck' 1 $ heightVal == 0 - - log "Able to get the offsetWidth of an element" - widthVal <- offsetWidth testDiv1 - quickCheck' 1 $ widthVal == 0 - - log "Able to get the offsetTop of an element" - topVal <- offsetTop testDiv1 - quickCheck' 1 $ topVal == 0 - - log "Able to get the offsetLeft of an element" - leftVal <- offsetLeft testDiv1 - quickCheck' 1 $ leftVal == 0 - - -- Unavailable in Zombie - -- log "Able to add a class" - - --hasTestClass1 <- classContains "testClass" testDiv1 - -- quickCheck' 1 $ hasTestClass1 == false - - -- classAdd "testClass" testDiv1 - -- hasTestClass2 <- classContains "testClass" testDiv1 - -- quickCheck' 1 $ hasTestClass2 == true From f957a03136ecd61c91568f662c74e06e4e84fc05 Mon Sep 17 00:00:00 2001 From: Nickolay Kudasov Date: Fri, 26 Aug 2016 13:25:27 +0300 Subject: [PATCH 3/6] Remove src/.webpack.js from repo and update .gitignore --- .gitignore | 11 ++++++----- src/.webpack.js | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 src/.webpack.js diff --git a/.gitignore b/.gitignore index c7908f8..4d159c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -.psci -output/ -node_modules/ -bower_components/ -tmp/ +/bower_components/ +/node_modules/ +/.pulp-cache/ +/output/ +/.psci* +/src/.webpack.js diff --git a/src/.webpack.js b/src/.webpack.js deleted file mode 100644 index 2bac876..0000000 --- a/src/.webpack.js +++ /dev/null @@ -1 +0,0 @@ -require('./Main.purs').main(); From 522e8f215e19f0495c504da3a8828eca5f699f0f Mon Sep 17 00:00:00 2001 From: Nickolay Kudasov Date: Fri, 26 Aug 2016 13:26:37 +0300 Subject: [PATCH 4/6] Cleanup test/ a bit --- test/Test.js | 4 ---- test/Test.purs | 10 ++++------ test/test.html | 1 + 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/test/Test.js b/test/Test.js index 8ea3459..4641904 100644 --- a/test/Test.js +++ b/test/Test.js @@ -3,10 +3,6 @@ // module Test.Main -exports.inspect = function (msg) { - console.log(msg); -}; - exports.tagname = function (obj) { return obj.tagName; }; diff --git a/test/Test.purs b/test/Test.purs index 53067fd..125b8a1 100644 --- a/test/Test.purs +++ b/test/Test.purs @@ -1,6 +1,6 @@ module Test.Main where -import Prelude (Unit, bind, (==), ($), (>>=)) +import Prelude (bind) import Data.Array (length) import Data.Maybe (Maybe(..), isNothing) @@ -18,8 +18,6 @@ import Test.Spec.Runner (run) import Test.Spec.Assertions (shouldEqual) import Test.Spec.Reporter.Console (consoleReporter) -foreign import inspect :: forall a. a -> Unit - foreign import tagname :: forall a. a -> String main = run [consoleReporter] do @@ -53,19 +51,19 @@ main = run [consoleReporter] do it "Able to look up element by id" do doc <- liftEff (document globalWindow) Just testDiv <- liftEff (getElementById "test1" doc) - tagname testDiv `shouldEqual` "DIV" + tagname testDiv `shouldEqual` "DIV" content <- liftEff (textContent testDiv) content `shouldEqual` "testContent1" it "Able to look up element by class name" do doc <- liftEff (document globalWindow) Just testDiv <- liftEff (querySelector ".test2" doc) - tagname testDiv `shouldEqual` "DIV" + tagname testDiv `shouldEqual` "DIV" content <- liftEff (textContent testDiv) content `shouldEqual` "testContent2" it "Able to look up element by tag name" do doc <- liftEff (document globalWindow) Just testDiv <- liftEff (querySelector "test3" doc) - tagname testDiv `shouldEqual` "DIV" + tagname testDiv `shouldEqual` "DIV" content <- liftEff (textContent testDiv) content `shouldEqual` "testContent3" it "Able to count items in a nodelist" do diff --git a/test/test.html b/test/test.html index bf53091..2327eaf 100644 --- a/test/test.html +++ b/test/test.html @@ -9,5 +9,6 @@ testContent3 + From c73691dfef1ac945965e761d97d36c34d2cb8bca Mon Sep 17 00:00:00 2001 From: Nickolay Kudasov Date: Fri, 26 Aug 2016 13:26:56 +0300 Subject: [PATCH 5/6] Remove js/ dir --- js/index.js | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 js/index.js diff --git a/js/index.js b/js/index.js deleted file mode 100644 index 570ee80..0000000 --- a/js/index.js +++ /dev/null @@ -1,7 +0,0 @@ -var Browser = require("zombie"); -var assert = require("assert"); - -Browser.visit("file://" + __dirname + "/../tests/test.html", function (e, browser, status) { - window = browser.document.window; - require("Main").main(); -}); From 9ecdf32892f5480d3014b4ff142e7f8922794a00 Mon Sep 17 00:00:00 2001 From: Nickolay Kudasov Date: Fri, 26 Aug 2016 13:28:35 +0300 Subject: [PATCH 6/6] Update docs --- docs/Data/DOM/Simple/Ajax.md | 18 +-- docs/Data/DOM/Simple/Document.md | 18 +-- docs/Data/DOM/Simple/Element.md | 64 +++++------ docs/Data/DOM/Simple/Encode.md | 2 +- docs/Data/DOM/Simple/Events.md | 140 ++++++++++++++++-------- docs/Data/DOM/Simple/Navigator.md | 16 +-- docs/Data/DOM/Simple/NodeList.md | 10 +- docs/Data/DOM/Simple/Unsafe/Ajax.md | 2 +- docs/Data/DOM/Simple/Unsafe/Document.md | 10 +- docs/Data/DOM/Simple/Unsafe/Element.md | 66 +++++------ docs/Data/DOM/Simple/Unsafe/Events.md | 28 +++-- docs/Data/DOM/Simple/Unsafe/Utils.md | 6 + docs/Data/DOM/Simple/Unsafe/Window.md | 34 ++++-- docs/Data/DOM/Simple/Window.md | 28 ++--- 14 files changed, 260 insertions(+), 182 deletions(-) diff --git a/docs/Data/DOM/Simple/Ajax.md b/docs/Data/DOM/Simple/Ajax.md index 6510121..0cdee64 100644 --- a/docs/Data/DOM/Simple/Ajax.md +++ b/docs/Data/DOM/Simple/Ajax.md @@ -9,7 +9,7 @@ data ReadyState | HeadersReceived | Loading | Done - | Unknown Int + | UnknownState Int ``` #### `Url` @@ -35,7 +35,7 @@ data HttpMethod ##### Instances ``` purescript -instance showHttpMethod :: Show HttpMethod +Show HttpMethod ``` #### `ResponseType` @@ -55,7 +55,7 @@ data ResponseType ##### Instances ``` purescript -instance showResponseType :: Show ResponseType +Show ResponseType ``` #### `ArrayBuffer` @@ -99,7 +99,7 @@ data HttpData a #### `makeXMLHttpRequest` ``` purescript -makeXMLHttpRequest :: forall eff. Eff (dom :: DOM | eff) XMLHttpRequest +makeXMLHttpRequest :: forall eff. (Eff (dom :: DOM | eff) XMLHttpRequest) ``` #### `readyState` @@ -147,7 +147,7 @@ response :: forall eff a. XMLHttpRequest -> Eff (dom :: DOM | eff) (HttpData a) #### `responseText` ``` purescript -responseText :: forall eff. XMLHttpRequest -> Eff (dom :: DOM | eff) String +responseText :: forall eff. XMLHttpRequest -> (Eff (dom :: DOM | eff) String) ``` #### `status` @@ -159,19 +159,19 @@ status :: forall eff. XMLHttpRequest -> Eff (dom :: DOM | eff) Int #### `statusText` ``` purescript -statusText :: forall eff. XMLHttpRequest -> Eff (dom :: DOM | eff) String +statusText :: forall eff. XMLHttpRequest -> (Eff (dom :: DOM | eff) String) ``` #### `setRequestHeader` ``` purescript -setRequestHeader :: forall eff. String -> String -> XMLHttpRequest -> Eff (dom :: DOM | eff) Unit +setRequestHeader :: forall eff. String -> String -> XMLHttpRequest -> (Eff (dom :: DOM | eff) Unit) ``` #### `getAllResponseHeaders` ``` purescript -getAllResponseHeaders :: forall eff. XMLHttpRequest -> Eff (dom :: DOM | eff) String +getAllResponseHeaders :: forall eff. XMLHttpRequest -> (Eff (dom :: DOM | eff) String) ``` #### `getResponseHeader` @@ -183,7 +183,7 @@ getResponseHeader :: forall eff. String -> XMLHttpRequest -> Eff (dom :: DOM | e #### `overrideMimeType` ``` purescript -overrideMimeType :: forall eff. String -> XMLHttpRequest -> Eff (dom :: DOM | eff) Unit +overrideMimeType :: forall eff. String -> XMLHttpRequest -> (Eff (dom :: DOM | eff) Unit) ``` diff --git a/docs/Data/DOM/Simple/Document.md b/docs/Data/DOM/Simple/Document.md index 849d464..e3d9124 100644 --- a/docs/Data/DOM/Simple/Document.md +++ b/docs/Data/DOM/Simple/Document.md @@ -8,25 +8,25 @@ data HTMLDocument :: * ##### Instances ``` purescript -instance htmlDocumentElement :: Element HTMLDocument -instance htmlDocument :: Document HTMLDocument -instance showHtmlDocument :: Show HTMLDocument +Element HTMLDocument +Document HTMLDocument +Show HTMLDocument ``` #### `Document` ``` purescript class Document b where - title :: forall eff. b -> Eff (dom :: DOM | eff) String - setTitle :: forall eff. String -> b -> Eff (dom :: DOM | eff) Unit - body :: forall eff. b -> Eff (dom :: DOM | eff) HTMLElement - setBody :: forall eff. HTMLElement -> b -> Eff (dom :: DOM | eff) Unit - createElement :: forall eff. String -> b -> Eff (dom :: DOM | eff) HTMLElement + title :: forall eff. b -> (Eff (dom :: DOM | eff) String) + setTitle :: forall eff. String -> b -> (Eff (dom :: DOM | eff) Unit) + body :: forall eff. b -> (Eff (dom :: DOM | eff) HTMLElement) + setBody :: forall eff. HTMLElement -> b -> (Eff (dom :: DOM | eff) Unit) + createElement :: forall eff. String -> b -> (Eff (dom :: DOM | eff) HTMLElement) ``` ##### Instances ``` purescript -instance htmlDocument :: Document HTMLDocument +Document HTMLDocument ``` diff --git a/docs/Data/DOM/Simple/Element.md b/docs/Data/DOM/Simple/Element.md index 95e7638..f05cd05 100644 --- a/docs/Data/DOM/Simple/Element.md +++ b/docs/Data/DOM/Simple/Element.md @@ -4,52 +4,52 @@ ``` purescript class Element b where - getElementById :: forall eff. String -> b -> Eff (dom :: DOM | eff) (Maybe HTMLElement) - getElementsByClassName :: forall eff. String -> b -> Eff (dom :: DOM | eff) (Array HTMLElement) - getElementsByName :: forall eff. String -> b -> Eff (dom :: DOM | eff) (Array HTMLElement) - querySelector :: forall eff. String -> b -> Eff (dom :: DOM | eff) (Maybe HTMLElement) - querySelectorAll :: forall eff. String -> b -> Eff (dom :: DOM | eff) NodeList - getAttribute :: forall eff. String -> b -> Eff (dom :: DOM | eff) String - setAttribute :: forall eff. String -> String -> b -> Eff (dom :: DOM | eff) Unit - hasAttribute :: forall eff. String -> b -> Eff (dom :: DOM | eff) Boolean - removeAttribute :: forall eff. String -> b -> Eff (dom :: DOM | eff) Unit - getStyleAttr :: forall eff. String -> b -> Eff (dom :: DOM | eff) String - setStyleAttr :: forall eff. String -> String -> b -> Eff (dom :: DOM | eff) Unit - children :: forall eff. b -> Eff (dom :: DOM | eff) (Array HTMLElement) - appendChild :: forall eff. b -> HTMLElement -> Eff (dom :: DOM | eff) Unit - innerHTML :: forall eff. b -> Eff (dom :: DOM | eff) String - setInnerHTML :: forall eff. String -> b -> Eff (dom :: DOM | eff) Unit - textContent :: forall eff. b -> Eff (dom :: DOM | eff) String - setTextContent :: forall eff. String -> b -> Eff (dom :: DOM | eff) Unit - value :: forall eff. b -> Eff (dom :: DOM | eff) String - setValue :: forall eff. String -> b -> Eff (dom :: DOM | eff) Unit - contentWindow :: forall eff. b -> Eff (dom :: DOM | eff) HTMLWindow - classRemove :: forall eff. String -> b -> Eff (dom :: DOM | eff) Unit - classAdd :: forall eff. String -> b -> Eff (dom :: DOM | eff) Unit - classToggle :: forall eff. String -> b -> Eff (dom :: DOM | eff) Unit - classContains :: forall eff. String -> b -> Eff (dom :: DOM | eff) Boolean - offsetParent :: forall eff. b -> Eff (dom :: DOM | eff) (Maybe HTMLElement) - offsetHeight :: forall eff. b -> Eff (dom :: DOM | eff) Int - offsetWidth :: forall eff. b -> Eff (dom :: DOM | eff) Int - offsetTop :: forall eff. b -> Eff (dom :: DOM | eff) Int - offsetLeft :: forall eff. b -> Eff (dom :: DOM | eff) Int + getElementById :: forall eff. String -> b -> (Eff (dom :: DOM | eff) (Maybe HTMLElement)) + getElementsByClassName :: forall eff. String -> b -> (Eff (dom :: DOM | eff) (Array HTMLElement)) + getElementsByName :: forall eff. String -> b -> (Eff (dom :: DOM | eff) (Array HTMLElement)) + querySelector :: forall eff. String -> b -> (Eff (dom :: DOM | eff) (Maybe HTMLElement)) + querySelectorAll :: forall eff. String -> b -> (Eff (dom :: DOM | eff) NodeList) + getAttribute :: forall eff. String -> b -> (Eff (dom :: DOM | eff) String) + setAttribute :: forall eff. String -> String -> b -> (Eff (dom :: DOM | eff) Unit) + hasAttribute :: forall eff. String -> b -> (Eff (dom :: DOM | eff) Boolean) + removeAttribute :: forall eff. String -> b -> (Eff (dom :: DOM | eff) Unit) + getStyleAttr :: forall eff. String -> b -> (Eff (dom :: DOM | eff) String) + setStyleAttr :: forall eff. String -> String -> b -> (Eff (dom :: DOM | eff) Unit) + children :: forall eff. b -> (Eff (dom :: DOM | eff) (Array HTMLElement)) + appendChild :: forall eff. b -> HTMLElement -> (Eff (dom :: DOM | eff) Unit) + innerHTML :: forall eff. b -> (Eff (dom :: DOM | eff) String) + setInnerHTML :: forall eff. String -> b -> (Eff (dom :: DOM | eff) Unit) + textContent :: forall eff. b -> (Eff (dom :: DOM | eff) String) + setTextContent :: forall eff. String -> b -> (Eff (dom :: DOM | eff) Unit) + value :: forall eff. b -> (Eff (dom :: DOM | eff) String) + setValue :: forall eff. String -> b -> (Eff (dom :: DOM | eff) Unit) + contentWindow :: forall eff. b -> (Eff (dom :: DOM | eff) HTMLWindow) + classRemove :: forall eff. String -> b -> (Eff (dom :: DOM | eff) Unit) + classAdd :: forall eff. String -> b -> (Eff (dom :: DOM | eff) Unit) + classToggle :: forall eff. String -> b -> (Eff (dom :: DOM | eff) Unit) + classContains :: forall eff. String -> b -> (Eff (dom :: DOM | eff) Boolean) + offsetParent :: forall eff. b -> (Eff (dom :: DOM | eff) (Maybe HTMLElement)) + offsetHeight :: forall eff. b -> (Eff (dom :: DOM | eff) Int) + offsetWidth :: forall eff. b -> (Eff (dom :: DOM | eff) Int) + offsetTop :: forall eff. b -> (Eff (dom :: DOM | eff) Int) + offsetLeft :: forall eff. b -> (Eff (dom :: DOM | eff) Int) ``` ##### Instances ``` purescript -instance htmlElement :: Element HTMLElement +Element HTMLElement ``` #### `setAttributes` ``` purescript -setAttributes :: forall eff a. (Element a) => Array (Tuple String String) -> a -> Eff (dom :: DOM | eff) Unit +setAttributes :: forall eff a. Element a => Array (Tuple String String) -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `setStyleAttrs` ``` purescript -setStyleAttrs :: forall eff a. (Element a) => Array (Tuple String String) -> a -> Eff (dom :: DOM | eff) Unit +setStyleAttrs :: forall eff a. Element a => Array (Tuple String String) -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `click` diff --git a/docs/Data/DOM/Simple/Encode.md b/docs/Data/DOM/Simple/Encode.md index 3f4815f..4e91a7f 100644 --- a/docs/Data/DOM/Simple/Encode.md +++ b/docs/Data/DOM/Simple/Encode.md @@ -35,7 +35,7 @@ Given an object, convert it into URL parameters. #### `toJsonString` ``` purescript -toJsonString :: forall eff a. a -> Eff (dom :: DOM | eff) String +toJsonString :: forall eff a. a -> (Eff (dom :: DOM | eff) String) ``` Given an object, convert it into a JSON string diff --git a/docs/Data/DOM/Simple/Events.md b/docs/Data/DOM/Simple/Events.md index 0b1bccc..2ded0a3 100644 --- a/docs/Data/DOM/Simple/Events.md +++ b/docs/Data/DOM/Simple/Events.md @@ -9,23 +9,23 @@ class Read s where ##### Instances ``` purescript -instance mouseEventTypeRead :: Read MouseEventType -instance keyboardEventTypeRead :: Read KeyboardEventType -instance uiEventTypeRead :: Read UIEventType +Read MouseEventType +Read KeyboardEventType +Read UIEventType ``` #### `Event` ``` purescript class Event e where - eventTarget :: forall eff a. e -> Eff (dom :: DOM | eff) a - stopPropagation :: forall eff. e -> Eff (dom :: DOM | eff) Unit - preventDefault :: forall eff. e -> Eff (dom :: DOM | eff) Unit + eventTarget :: forall eff a. e -> (Eff (dom :: DOM | eff) a) + stopPropagation :: forall eff. e -> (Eff (dom :: DOM | eff) Unit) + preventDefault :: forall eff. e -> (Eff (dom :: DOM | eff) Unit) ``` ##### Instances ``` purescript -instance eventDOMEvent :: Event DOMEvent +Event DOMEvent ``` #### `MouseEventType` @@ -46,39 +46,39 @@ data MouseEventType ##### Instances ``` purescript -instance mouseEventTypeShow :: Show MouseEventType -instance mouseEventTypeRead :: Read MouseEventType +Show MouseEventType +Read MouseEventType ``` #### `MouseEvent` ``` purescript class (Event e) <= MouseEvent e where - mouseEventType :: forall eff. e -> Eff (dom :: DOM | eff) MouseEventType - screenX :: forall eff. e -> Eff (dom :: DOM | eff) Int - screenY :: forall eff. e -> Eff (dom :: DOM | eff) Int - clientX :: forall eff. e -> Eff (dom :: DOM | eff) Int - clientY :: forall eff. e -> Eff (dom :: DOM | eff) Int + mouseEventType :: forall eff. e -> (Eff (dom :: DOM | eff) MouseEventType) + screenX :: forall eff. e -> (Eff (dom :: DOM | eff) Int) + screenY :: forall eff. e -> (Eff (dom :: DOM | eff) Int) + clientX :: forall eff. e -> (Eff (dom :: DOM | eff) Int) + clientY :: forall eff. e -> (Eff (dom :: DOM | eff) Int) ``` ##### Instances ``` purescript -instance mouseEventDOMEvent :: MouseEvent DOMEvent +MouseEvent DOMEvent ``` #### `MouseEventTarget` ``` purescript class MouseEventTarget b where - addMouseEventListener :: forall e t ta. (MouseEvent e) => MouseEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> Eff (dom :: DOM | ta) Unit - removeMouseEventListener :: forall e t ta. (MouseEvent e) => MouseEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> Eff (dom :: DOM | ta) Unit + addMouseEventListener :: forall e t ta. MouseEvent e => MouseEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> (Eff (dom :: DOM | ta) Unit) + removeMouseEventListener :: forall e t ta. MouseEvent e => MouseEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> (Eff (dom :: DOM | ta) Unit) ``` ##### Instances ``` purescript -instance mouseEventTargetHTMLWindow :: MouseEventTarget HTMLWindow -instance mouseEventTargetHTMLDocument :: MouseEventTarget HTMLDocument -instance mouseEventTargetHTMLElement :: MouseEventTarget HTMLElement +MouseEventTarget HTMLWindow +MouseEventTarget HTMLDocument +MouseEventTarget HTMLElement ``` #### `KeyboardEventType` @@ -93,8 +93,8 @@ data KeyboardEventType ##### Instances ``` purescript -instance keyboardEventTypeShow :: Show KeyboardEventType -instance keyboardEventTypeRead :: Read KeyboardEventType +Show KeyboardEventType +Read KeyboardEventType ``` #### `KeyLocation` @@ -118,34 +118,34 @@ toKeyLocation :: Int -> KeyLocation ``` purescript class (Event e) <= KeyboardEvent e where - keyboardEventType :: forall eff. e -> Eff (dom :: DOM | eff) KeyboardEventType - key :: forall eff. e -> Eff (dom :: DOM | eff) String - keyCode :: forall eff. e -> Eff (dom :: DOM | eff) Int - keyLocation :: forall eff. e -> Eff (dom :: DOM | eff) KeyLocation - altKey :: forall eff. e -> Eff (dom :: DOM | eff) Boolean - ctrlKey :: forall eff. e -> Eff (dom :: DOM | eff) Boolean - metaKey :: forall eff. e -> Eff (dom :: DOM | eff) Boolean - shiftKey :: forall eff. e -> Eff (dom :: DOM | eff) Boolean + keyboardEventType :: forall eff. e -> (Eff (dom :: DOM | eff) KeyboardEventType) + key :: forall eff. e -> (Eff (dom :: DOM | eff) String) + keyCode :: forall eff. e -> (Eff (dom :: DOM | eff) Int) + keyLocation :: forall eff. e -> (Eff (dom :: DOM | eff) KeyLocation) + altKey :: forall eff. e -> (Eff (dom :: DOM | eff) Boolean) + ctrlKey :: forall eff. e -> (Eff (dom :: DOM | eff) Boolean) + metaKey :: forall eff. e -> (Eff (dom :: DOM | eff) Boolean) + shiftKey :: forall eff. e -> (Eff (dom :: DOM | eff) Boolean) ``` ##### Instances ``` purescript -instance keyboardEventDOMEvent :: KeyboardEvent DOMEvent +KeyboardEvent DOMEvent ``` #### `KeyboardEventTarget` ``` purescript class KeyboardEventTarget b where - addKeyboardEventListener :: forall e t ta. (KeyboardEvent e) => KeyboardEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> Eff (dom :: DOM | ta) Unit - removeKeyboardEventListener :: forall e t ta. (KeyboardEvent e) => KeyboardEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> Eff (dom :: DOM | ta) Unit + addKeyboardEventListener :: forall e t ta. KeyboardEvent e => KeyboardEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> (Eff (dom :: DOM | ta) Unit) + removeKeyboardEventListener :: forall e t ta. KeyboardEvent e => KeyboardEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> (Eff (dom :: DOM | ta) Unit) ``` ##### Instances ``` purescript -instance keyboardEventTargetHTMLWindow :: KeyboardEventTarget HTMLWindow -instance keyboardEventTargetHTMLDocument :: KeyboardEventTarget HTMLDocument -instance keyboardEventTargetHTMLElement :: KeyboardEventTarget HTMLElement +KeyboardEventTarget HTMLWindow +KeyboardEventTarget HTMLDocument +KeyboardEventTarget HTMLElement ``` #### `UIEventType` @@ -164,34 +164,86 @@ data UIEventType ##### Instances ``` purescript -instance uiEventTypeShow :: Show UIEventType -instance uiEventTypeRead :: Read UIEventType +Show UIEventType +Read UIEventType ``` #### `UIEvent` ``` purescript class (Event e) <= UIEvent e where - view :: forall eff. e -> Eff (dom :: DOM | eff) HTMLWindow - detail :: forall eff. e -> Eff (dom :: DOM | eff) Int + view :: forall eff. e -> (Eff (dom :: DOM | eff) HTMLWindow) + detail :: forall eff. e -> (Eff (dom :: DOM | eff) Int) ``` ##### Instances ``` purescript -instance uiEventDOMEvent :: UIEvent DOMEvent +UIEvent DOMEvent ``` #### `UIEventTarget` ``` purescript class UIEventTarget b where - addUIEventListener :: forall e t ta. (UIEvent e) => UIEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> Eff (dom :: DOM | ta) Unit - removeUIEventListener :: forall e t ta. (UIEvent e) => UIEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> Eff (dom :: DOM | ta) Unit + addUIEventListener :: forall e t ta. UIEvent e => UIEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> (Eff (dom :: DOM | ta) Unit) + removeUIEventListener :: forall e t ta. UIEvent e => UIEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> (Eff (dom :: DOM | ta) Unit) ``` ##### Instances ``` purescript -instance uiEventTargetHTMLWindow :: UIEventTarget HTMLWindow +UIEventTarget HTMLWindow +``` + +#### `ProgressEventType` + +``` purescript +data ProgressEventType + = ProgressAbortEvent + | ProgressErrorEvent + | ProgressLoadEvent + | ProgressLoadEndEvent + | ProgressLoadStartEvent + | ProgressProgressEvent + | ProgressTimeoutEvent +``` + +##### Instances +``` purescript +Show ProgressEventType +``` + +#### `readProgressEventType` + +``` purescript +readProgressEventType :: Partial => String -> ProgressEventType +``` + +#### `ProgressEvent` + +``` purescript +class (Event e) <= ProgressEvent e where + progressEventType :: forall eff. e -> (Eff (dom :: DOM | eff) ProgressEventType) + lengthComputable :: forall eff. e -> (Eff (dom :: DOM | eff) Boolean) + loaded :: forall eff. e -> (Eff (dom :: DOM | eff) Number) + total :: forall eff. e -> (Eff (dom :: DOM | eff) Number) +``` + +##### Instances +``` purescript +ProgressEvent DOMEvent +``` + +#### `ProgressEventTarget` + +``` purescript +class ProgressEventTarget b where + addProgressEventListener :: forall e t ta. ProgressEvent e => ProgressEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> (Eff (dom :: DOM | ta) Unit) + removeProgressEventListener :: forall e t ta. ProgressEvent e => ProgressEventType -> (e -> Eff (dom :: DOM | t) Unit) -> b -> (Eff (dom :: DOM | ta) Unit) +``` + +##### Instances +``` purescript +ProgressEventTarget XMLHttpRequest ``` diff --git a/docs/Data/DOM/Simple/Navigator.md b/docs/Data/DOM/Simple/Navigator.md index d6e8a6a..8d4e3d7 100644 --- a/docs/Data/DOM/Simple/Navigator.md +++ b/docs/Data/DOM/Simple/Navigator.md @@ -4,18 +4,18 @@ ``` purescript class Navigator b where - appName :: forall eff. b -> Eff (dom :: DOM | eff) String - appVersion :: forall eff. b -> Eff (dom :: DOM | eff) String - appCodeName :: forall eff. b -> Eff (dom :: DOM | eff) String - language :: forall eff. b -> Eff (dom :: DOM | eff) String - platform :: forall eff. b -> Eff (dom :: DOM | eff) String - product :: forall eff. b -> Eff (dom :: DOM | eff) String - userAgent :: forall eff. b -> Eff (dom :: DOM | eff) String + appName :: forall eff. b -> (Eff (dom :: DOM | eff) String) + appVersion :: forall eff. b -> (Eff (dom :: DOM | eff) String) + appCodeName :: forall eff. b -> (Eff (dom :: DOM | eff) String) + language :: forall eff. b -> (Eff (dom :: DOM | eff) String) + platform :: forall eff. b -> (Eff (dom :: DOM | eff) String) + product :: forall eff. b -> (Eff (dom :: DOM | eff) String) + userAgent :: forall eff. b -> (Eff (dom :: DOM | eff) String) ``` ##### Instances ``` purescript -instance domNavigator :: Navigator DOMNavigator +Navigator DOMNavigator ``` diff --git a/docs/Data/DOM/Simple/NodeList.md b/docs/Data/DOM/Simple/NodeList.md index 174dc63..c9dcb43 100644 --- a/docs/Data/DOM/Simple/NodeList.md +++ b/docs/Data/DOM/Simple/NodeList.md @@ -4,25 +4,25 @@ ``` purescript class NodeListInst b where - length :: forall eff. b -> Eff (dom :: DOM | eff) Int - item :: forall eff. Int -> b -> Eff (dom :: DOM | eff) (Maybe HTMLElement) + length :: forall eff. b -> (Eff (dom :: DOM | eff) Int) + item :: forall eff. Int -> b -> (Eff (dom :: DOM | eff) (Maybe HTMLElement)) ``` ##### Instances ``` purescript -instance nodeList :: NodeListInst NodeList +NodeListInst NodeList ``` #### `nodeListToArray` ``` purescript -nodeListToArray :: forall eff. NodeList -> Eff (dom :: DOM | eff) (Array HTMLElement) +nodeListToArray :: forall eff. NodeList -> (Eff (dom :: DOM | eff) (Array HTMLElement)) ``` #### `nodeListToArray'` ``` purescript -nodeListToArray' :: forall eff. NodeList -> Eff (dom :: DOM | eff) (Array HTMLElement) +nodeListToArray' :: forall eff. NodeList -> (Eff (dom :: DOM | eff) (Array HTMLElement)) ``` diff --git a/docs/Data/DOM/Simple/Unsafe/Ajax.md b/docs/Data/DOM/Simple/Unsafe/Ajax.md index e2f6b33..e5c45f8 100644 --- a/docs/Data/DOM/Simple/Unsafe/Ajax.md +++ b/docs/Data/DOM/Simple/Unsafe/Ajax.md @@ -51,7 +51,7 @@ unsafeResponse :: forall eff a. XMLHttpRequest -> Eff (dom :: DOM | eff) a #### `unsafeGetResponseHeader` ``` purescript -unsafeGetResponseHeader :: forall eff a. Fn2 XMLHttpRequest String (Eff (dom :: DOM | eff) String) +unsafeGetResponseHeader :: forall eff. Fn2 XMLHttpRequest String (Eff (dom :: DOM | eff) String) ``` diff --git a/docs/Data/DOM/Simple/Unsafe/Document.md b/docs/Data/DOM/Simple/Unsafe/Document.md index 95debd2..05ebee4 100644 --- a/docs/Data/DOM/Simple/Unsafe/Document.md +++ b/docs/Data/DOM/Simple/Unsafe/Document.md @@ -3,31 +3,31 @@ #### `unsafeTitle` ``` purescript -unsafeTitle :: forall eff a. a -> Eff (dom :: DOM | eff) String +unsafeTitle :: forall eff a. a -> (Eff (dom :: DOM | eff) String) ``` #### `unsafeSetTitle` ``` purescript -unsafeSetTitle :: forall eff a. String -> a -> Eff (dom :: DOM | eff) Unit +unsafeSetTitle :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeBody` ``` purescript -unsafeBody :: forall eff a. a -> Eff (dom :: DOM | eff) HTMLElement +unsafeBody :: forall eff a. a -> (Eff (dom :: DOM | eff) HTMLElement) ``` #### `unsafeSetBody` ``` purescript -unsafeSetBody :: forall eff a. HTMLElement -> a -> Eff (dom :: DOM | eff) Unit +unsafeSetBody :: forall eff a. HTMLElement -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeCreateElement` ``` purescript -unsafeCreateElement :: forall eff a. String -> a -> Eff (dom :: DOM | eff) HTMLElement +unsafeCreateElement :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) HTMLElement) ``` diff --git a/docs/Data/DOM/Simple/Unsafe/Element.md b/docs/Data/DOM/Simple/Unsafe/Element.md index 734706d..39b9e53 100644 --- a/docs/Data/DOM/Simple/Unsafe/Element.md +++ b/docs/Data/DOM/Simple/Unsafe/Element.md @@ -8,199 +8,199 @@ data HTMLElement :: * ##### Instances ``` purescript -instance showHtmlElement :: Show HTMLElement +Show HTMLElement ``` #### `unsafeGetElementById` ``` purescript -unsafeGetElementById :: forall eff a. String -> a -> Eff (dom :: DOM | eff) HTMLElement +unsafeGetElementById :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) HTMLElement) ``` #### `unsafeGetElementsByClassName` ``` purescript -unsafeGetElementsByClassName :: forall eff a. String -> a -> Eff (dom :: DOM | eff) (Array HTMLElement) +unsafeGetElementsByClassName :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) (Array HTMLElement)) ``` #### `unsafeGetElementsByName` ``` purescript -unsafeGetElementsByName :: forall eff a. String -> a -> Eff (dom :: DOM | eff) (Array HTMLElement) +unsafeGetElementsByName :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) (Array HTMLElement)) ``` #### `unsafeQuerySelector` ``` purescript -unsafeQuerySelector :: forall eff a. String -> a -> Eff (dom :: DOM | eff) HTMLElement +unsafeQuerySelector :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) HTMLElement) ``` #### `unsafeQuerySelectorAll` ``` purescript -unsafeQuerySelectorAll :: forall eff a. String -> a -> Eff (dom :: DOM | eff) NodeList +unsafeQuerySelectorAll :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) NodeList) ``` #### `unsafeGetAttribute` ``` purescript -unsafeGetAttribute :: forall eff a. String -> a -> Eff (dom :: DOM | eff) String +unsafeGetAttribute :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) String) ``` #### `unsafeSetAttribute` ``` purescript -unsafeSetAttribute :: forall eff a. String -> String -> a -> Eff (dom :: DOM | eff) Unit +unsafeSetAttribute :: forall eff a. String -> String -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeHasAttribute` ``` purescript -unsafeHasAttribute :: forall eff a. String -> a -> Eff (dom :: DOM | eff) Boolean +unsafeHasAttribute :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) Boolean) ``` #### `unsafeRemoveAttribute` ``` purescript -unsafeRemoveAttribute :: forall eff a. String -> a -> Eff (dom :: DOM | eff) Unit +unsafeRemoveAttribute :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeGetStyleAttr` ``` purescript -unsafeGetStyleAttr :: forall eff a. String -> a -> Eff (dom :: DOM | eff) String +unsafeGetStyleAttr :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) String) ``` #### `unsafeSetStyleAttr` ``` purescript -unsafeSetStyleAttr :: forall eff a. String -> String -> a -> Eff (dom :: DOM | eff) Unit +unsafeSetStyleAttr :: forall eff a. String -> String -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeChildren` ``` purescript -unsafeChildren :: forall eff a. a -> Eff (dom :: DOM | eff) (Array HTMLElement) +unsafeChildren :: forall eff a. a -> (Eff (dom :: DOM | eff) (Array HTMLElement)) ``` #### `unsafeAppendChild` ``` purescript -unsafeAppendChild :: forall eff a. a -> HTMLElement -> Eff (dom :: DOM | eff) Unit +unsafeAppendChild :: forall eff a. a -> HTMLElement -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeInnerHTML` ``` purescript -unsafeInnerHTML :: forall eff a. a -> Eff (dom :: DOM | eff) String +unsafeInnerHTML :: forall eff a. a -> (Eff (dom :: DOM | eff) String) ``` #### `unsafeSetInnerHTML` ``` purescript -unsafeSetInnerHTML :: forall eff a. String -> a -> Eff (dom :: DOM | eff) Unit +unsafeSetInnerHTML :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeTextContent` ``` purescript -unsafeTextContent :: forall eff a. a -> Eff (dom :: DOM | eff) String +unsafeTextContent :: forall eff a. a -> (Eff (dom :: DOM | eff) String) ``` #### `unsafeSetTextContent` ``` purescript -unsafeSetTextContent :: forall eff a. String -> a -> Eff (dom :: DOM | eff) Unit +unsafeSetTextContent :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeValue` ``` purescript -unsafeValue :: forall eff a. a -> Eff (dom :: DOM | eff) String +unsafeValue :: forall eff a. a -> (Eff (dom :: DOM | eff) String) ``` #### `unsafeSetValue` ``` purescript -unsafeSetValue :: forall eff a. String -> a -> Eff (dom :: DOM | eff) Unit +unsafeSetValue :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeContentWindow` ``` purescript -unsafeContentWindow :: forall eff a. a -> Eff (dom :: DOM | eff) HTMLWindow +unsafeContentWindow :: forall eff a. a -> (Eff (dom :: DOM | eff) HTMLWindow) ``` #### `unsafeClassAdd` ``` purescript -unsafeClassAdd :: forall eff a. String -> a -> Eff (dom :: DOM | eff) Unit +unsafeClassAdd :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeClassRemove` ``` purescript -unsafeClassRemove :: forall eff a. String -> a -> Eff (dom :: DOM | eff) Unit +unsafeClassRemove :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeClassToggle` ``` purescript -unsafeClassToggle :: forall eff a. String -> a -> Eff (dom :: DOM | eff) Unit +unsafeClassToggle :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeClassContains` ``` purescript -unsafeClassContains :: forall eff a. String -> a -> Eff (dom :: DOM | eff) Boolean +unsafeClassContains :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) Boolean) ``` #### `unsafeClick` ``` purescript -unsafeClick :: forall eff a. a -> Eff (dom :: DOM | eff) Unit +unsafeClick :: forall eff a. a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeFocus` ``` purescript -unsafeFocus :: forall eff a. a -> Eff (dom :: DOM | eff) Unit +unsafeFocus :: forall eff a. a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeBlur` ``` purescript -unsafeBlur :: forall eff a. a -> Eff (dom :: DOM | eff) Unit +unsafeBlur :: forall eff a. a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeOffsetParent` ``` purescript -unsafeOffsetParent :: forall eff a. a -> Eff (dom :: DOM | eff) HTMLElement +unsafeOffsetParent :: forall eff a. a -> (Eff (dom :: DOM | eff) HTMLElement) ``` #### `unsafeOffsetHeight` ``` purescript -unsafeOffsetHeight :: forall eff a. a -> Eff (dom :: DOM | eff) Int +unsafeOffsetHeight :: forall eff a. a -> (Eff (dom :: DOM | eff) Int) ``` #### `unsafeOffsetWidth` ``` purescript -unsafeOffsetWidth :: forall eff a. a -> Eff (dom :: DOM | eff) Int +unsafeOffsetWidth :: forall eff a. a -> (Eff (dom :: DOM | eff) Int) ``` #### `unsafeOffsetTop` ``` purescript -unsafeOffsetTop :: forall eff a. a -> Eff (dom :: DOM | eff) Int +unsafeOffsetTop :: forall eff a. a -> (Eff (dom :: DOM | eff) Int) ``` #### `unsafeOffsetLeft` ``` purescript -unsafeOffsetLeft :: forall eff a. a -> Eff (dom :: DOM | eff) Int +unsafeOffsetLeft :: forall eff a. a -> (Eff (dom :: DOM | eff) Int) ``` diff --git a/docs/Data/DOM/Simple/Unsafe/Events.md b/docs/Data/DOM/Simple/Unsafe/Events.md index cfd6d17..0ed43c7 100644 --- a/docs/Data/DOM/Simple/Unsafe/Events.md +++ b/docs/Data/DOM/Simple/Unsafe/Events.md @@ -3,67 +3,73 @@ #### `unsafeAddEventListener` ``` purescript -unsafeAddEventListener :: forall eff t e b. String -> (e -> Eff (dom :: DOM | t) Unit) -> b -> Eff (dom :: DOM | eff) Unit +unsafeAddEventListener :: forall eff t e b. String -> (e -> Eff (dom :: DOM | t) Unit) -> b -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeRemoveEventListener` ``` purescript -unsafeRemoveEventListener :: forall eff t e b. String -> (e -> Eff (dom :: DOM | t) Unit) -> b -> Eff (dom :: DOM | eff) Unit +unsafeRemoveEventListener :: forall eff t e b. String -> (e -> Eff (dom :: DOM | t) Unit) -> b -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeEventTarget` ``` purescript -unsafeEventTarget :: forall eff a. DOMEvent -> Eff (dom :: DOM | eff) a +unsafeEventTarget :: forall eff a. DOMEvent -> (Eff (dom :: DOM | eff) a) ``` #### `unsafeStopPropagation` ``` purescript -unsafeStopPropagation :: forall eff. DOMEvent -> Eff (dom :: DOM | eff) Unit +unsafeStopPropagation :: forall eff. DOMEvent -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafePreventDefault` ``` purescript -unsafePreventDefault :: forall eff. DOMEvent -> Eff (dom :: DOM | eff) Unit +unsafePreventDefault :: forall eff. DOMEvent -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeEventKey` ``` purescript -unsafeEventKey :: forall eff. DOMEvent -> Eff (dom :: DOM | eff) String +unsafeEventKey :: forall eff. DOMEvent -> (Eff (dom :: DOM | eff) String) ``` #### `unsafeEventKeyCode` ``` purescript -unsafeEventKeyCode :: forall eff. DOMEvent -> Eff (dom :: DOM | eff) Int +unsafeEventKeyCode :: forall eff. DOMEvent -> (Eff (dom :: DOM | eff) Int) ``` #### `unsafeEventNumberProp` ``` purescript -unsafeEventNumberProp :: forall eff. String -> DOMEvent -> Eff (dom :: DOM | eff) Int +unsafeEventNumberProp :: forall eff. String -> DOMEvent -> (Eff (dom :: DOM | eff) Int) ``` #### `unsafeEventStringProp` ``` purescript -unsafeEventStringProp :: forall eff. String -> DOMEvent -> Eff (dom :: DOM | eff) String +unsafeEventStringProp :: forall eff. String -> DOMEvent -> (Eff (dom :: DOM | eff) String) ``` #### `unsafeEventBooleanProp` ``` purescript -unsafeEventBooleanProp :: forall eff. String -> DOMEvent -> Eff (dom :: DOM | eff) Boolean +unsafeEventBooleanProp :: forall eff. String -> DOMEvent -> (Eff (dom :: DOM | eff) Boolean) ``` #### `unsafeEventView` ``` purescript -unsafeEventView :: forall eff. DOMEvent -> Eff (dom :: DOM | eff) HTMLWindow +unsafeEventView :: forall eff. DOMEvent -> (Eff (dom :: DOM | eff) HTMLWindow) +``` + +#### `unsafeEventProp` + +``` purescript +unsafeEventProp :: forall v eff. String -> DOMEvent -> (Eff (dom :: DOM | eff) v) ``` diff --git a/docs/Data/DOM/Simple/Unsafe/Utils.md b/docs/Data/DOM/Simple/Unsafe/Utils.md index 3e70660..c2dfd54 100644 --- a/docs/Data/DOM/Simple/Unsafe/Utils.md +++ b/docs/Data/DOM/Simple/Unsafe/Utils.md @@ -6,6 +6,12 @@ ensure3 :: forall a. Maybe a -> (a -> Maybe a) -> a -> Maybe a ``` +#### `ensure` + +``` purescript +ensure :: forall a. a -> Maybe a +``` + #### `showImpl` ``` purescript diff --git a/docs/Data/DOM/Simple/Unsafe/Window.md b/docs/Data/DOM/Simple/Unsafe/Window.md index 68bf1e7..060e833 100644 --- a/docs/Data/DOM/Simple/Unsafe/Window.md +++ b/docs/Data/DOM/Simple/Unsafe/Window.md @@ -3,67 +3,79 @@ #### `unsafeDocument` ``` purescript -unsafeDocument :: forall eff a. a -> Eff (dom :: DOM | eff) HTMLDocument +unsafeDocument :: forall eff a. a -> (Eff (dom :: DOM | eff) HTMLDocument) ``` #### `unsafeNavigator` ``` purescript -unsafeNavigator :: forall eff a. a -> Eff (dom :: DOM | eff) DOMNavigator +unsafeNavigator :: forall eff a. a -> (Eff (dom :: DOM | eff) DOMNavigator) ``` #### `unsafeLocation` ``` purescript -unsafeLocation :: forall eff a. a -> Eff (dom :: DOM | eff) DOMLocation +unsafeLocation :: forall eff a. a -> (Eff (dom :: DOM | eff) DOMLocation) ``` #### `unsafeGetLocation` ``` purescript -unsafeGetLocation :: forall eff a. a -> Eff (dom :: DOM | eff) String +unsafeGetLocation :: forall eff a. a -> (Eff (dom :: DOM | eff) String) ``` #### `unsafeSetLocation` ``` purescript -unsafeSetLocation :: forall eff a. String -> a -> Eff (dom :: DOM | eff) Unit +unsafeSetLocation :: forall eff a. String -> a -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeGetSearchLocation` ``` purescript -unsafeGetSearchLocation :: forall eff a. a -> Eff (dom :: DOM | eff) String +unsafeGetSearchLocation :: forall eff a. a -> (Eff (dom :: DOM | eff) String) ``` #### `unsafeSetTimeout` ``` purescript -unsafeSetTimeout :: forall eff b. b -> Number -> Eff (dom :: DOM | eff) Unit -> Eff (dom :: DOM | eff) Timeout +unsafeSetTimeout :: forall eff b. b -> Number -> Eff (dom :: DOM | eff) Unit -> (Eff (dom :: DOM | eff) Timeout) ``` #### `unsafeSetInterval` ``` purescript -unsafeSetInterval :: forall eff b. b -> Number -> Eff (dom :: DOM | eff) Unit -> Eff (dom :: DOM | eff) Timeout +unsafeSetInterval :: forall eff b. b -> Number -> Eff (dom :: DOM | eff) Unit -> (Eff (dom :: DOM | eff) Timeout) ``` #### `unsafeClearTimeout` ``` purescript -unsafeClearTimeout :: forall eff b. b -> Timeout -> Eff (dom :: DOM | eff) Unit +unsafeClearTimeout :: forall eff b. b -> Timeout -> (Eff (dom :: DOM | eff) Unit) ``` #### `unsafeInnerWidth` ``` purescript -unsafeInnerWidth :: forall eff b. b -> Eff (dom :: DOM | eff) Number +unsafeInnerWidth :: forall eff b. b -> (Eff (dom :: DOM | eff) Number) ``` #### `unsafeInnerHeight` ``` purescript -unsafeInnerHeight :: forall eff b. b -> Eff (dom :: DOM | eff) Number +unsafeInnerHeight :: forall eff b. b -> (Eff (dom :: DOM | eff) Number) +``` + +#### `unsafePageXOffset` + +``` purescript +unsafePageXOffset :: forall eff b. b -> (Eff (dom :: DOM | eff) Number) +``` + +#### `unsafePageYOffset` + +``` purescript +unsafePageYOffset :: forall eff b. b -> (Eff (dom :: DOM | eff) Number) ``` diff --git a/docs/Data/DOM/Simple/Window.md b/docs/Data/DOM/Simple/Window.md index a8bc653..242544b 100644 --- a/docs/Data/DOM/Simple/Window.md +++ b/docs/Data/DOM/Simple/Window.md @@ -4,33 +4,35 @@ ``` purescript class Location b where - getLocation :: forall eff. b -> Eff (dom :: DOM | eff) String - setLocation :: forall eff. String -> b -> Eff (dom :: DOM | eff) Unit - search :: forall eff. b -> Eff (dom :: DOM | eff) String + getLocation :: forall eff. b -> (Eff (dom :: DOM | eff) String) + setLocation :: forall eff. String -> b -> (Eff (dom :: DOM | eff) Unit) + search :: forall eff. b -> (Eff (dom :: DOM | eff) String) ``` ##### Instances ``` purescript -instance domLocation :: Location DOMLocation +Location DOMLocation ``` #### `Window` ``` purescript class Window b where - document :: forall eff. b -> Eff (dom :: DOM | eff) HTMLDocument - navigator :: forall eff. b -> Eff (dom :: DOM | eff) DOMNavigator - location :: forall eff. b -> Eff (dom :: DOM | eff) DOMLocation - setTimeout :: forall eff. b -> Number -> Eff (dom :: DOM | eff) Unit -> Eff (dom :: DOM | eff) Timeout - setInterval :: forall eff. b -> Number -> Eff (dom :: DOM | eff) Unit -> Eff (dom :: DOM | eff) Timeout - clearTimeout :: forall eff. b -> Timeout -> Eff (dom :: DOM | eff) Unit - innerWidth :: forall eff. b -> Eff (dom :: DOM | eff) Number - innerHeight :: forall eff. b -> Eff (dom :: DOM | eff) Number + document :: forall eff. b -> (Eff (dom :: DOM | eff) HTMLDocument) + navigator :: forall eff. b -> (Eff (dom :: DOM | eff) DOMNavigator) + location :: forall eff. b -> (Eff (dom :: DOM | eff) DOMLocation) + setTimeout :: forall eff. b -> Number -> Eff (dom :: DOM | eff) Unit -> (Eff (dom :: DOM | eff) Timeout) + setInterval :: forall eff. b -> Number -> Eff (dom :: DOM | eff) Unit -> (Eff (dom :: DOM | eff) Timeout) + clearTimeout :: forall eff. b -> Timeout -> (Eff (dom :: DOM | eff) Unit) + innerWidth :: forall eff. b -> (Eff (dom :: DOM | eff) Number) + innerHeight :: forall eff. b -> (Eff (dom :: DOM | eff) Number) + pageXOffset :: forall eff. b -> (Eff (dom :: DOM | eff) Number) + pageYOffset :: forall eff. b -> (Eff (dom :: DOM | eff) Number) ``` ##### Instances ``` purescript -instance htmlWindow :: Window HTMLWindow +Window HTMLWindow ``` #### `globalWindow`