Created
September 15, 2015 19:08
-
-
Save DrBoolean/3c7a71cbf5fae5af7d84 to your computer and use it in GitHub Desktop.
IO reason
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
| // createView = {} -> Html | |
| //+ setHtml :: String -> Html -> IO DOM | |
| var setHtml = curry(function(sel, h){ | |
| return new IO(function() {return jQuery(sel).html(h) }) | |
| }) | |
| var updateDom = compose(setHtml('#tag-cloud'), createView) | |
| // IO(DOM) | |
| var app = updateDom({tags: []}); | |
| jQuery.ready(app.unsafePerformIO) // <--- actually finds '#tag-cloud' |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Keeping it all to 1
unsafePerformIOon domReady is pretty nice. Also chaining manyIOactions into 1 update is pleasant. Task and EventStream are both pure so most things (especially in node) don't needIO.One issue is nested
IOand code not running. I find the debug output sucks so it's hard to keep in your head what the type stack looks like. Transformers help, but really it's a debug output issue.It's entirely possible to add better debug output in functions like curry/compose as well as stringify each type (even the functions inside the
IO). It's just that no one has done it yet.