From 5376b4260b3539afc46924440463165d175ef36f Mon Sep 17 00:00:00 2001 From: James Brock Date: Mon, 25 Jan 2021 11:37:17 +0900 Subject: [PATCH 1/2] Explain how to aquire a Document I couldn't figure out how to acquire a `Document` until I googled for it and found this https://lobste.rs/s/wa99yt/coming_purescript_from_haskell_reflex I think we should explain this better. --- src/Web/DOM/Document.purs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Web/DOM/Document.purs b/src/Web/DOM/Document.purs index 8fbb3d8..46a9bd1 100644 --- a/src/Web/DOM/Document.purs +++ b/src/Web/DOM/Document.purs @@ -3,9 +3,22 @@ -- | -- | The DOM API doesn't actually give you any way of getting hold of a -- | `Document` by itself. To do that, you will need to look at one of the --- | other APIs which build on the DOM API. For example, `window.document` is +-- | other APIs which build on the DOM API. +-- | +-- | For example, `window.document` is -- | part of the HTML5 API, and so the relevant binding can be found in -- | `Web.HTML.Window`, which is part of the `purescript-web-html` package. +-- | So here is one way to acquire an HTML5 `Document` from functions +-- | in `purescript-web-html`: +-- | +-- | ```purescript +-- | import Web.HTML (window) +-- | import Web.HTML.Window (document) +-- | import Web.HTML.HTMLDocument (toDocument) +-- | +-- | do +-- | doc <- toDocument <$> document =<< window +-- | ``` module Web.DOM.Document ( Document , fromNode From 037884e1a1d791dee3b741b40cc822c4f803c6d7 Mon Sep 17 00:00:00 2001 From: James Brock Date: Mon, 25 Jan 2021 11:44:09 +0900 Subject: [PATCH 2/2] Update Document.purs Fix associativity mistake --- src/Web/DOM/Document.purs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Web/DOM/Document.purs b/src/Web/DOM/Document.purs index 46a9bd1..9b201a1 100644 --- a/src/Web/DOM/Document.purs +++ b/src/Web/DOM/Document.purs @@ -17,7 +17,7 @@ -- | import Web.HTML.HTMLDocument (toDocument) -- | -- | do --- | doc <- toDocument <$> document =<< window +-- | doc <- map toDocument $ document =<< window -- | ``` module Web.DOM.Document ( Document