Skip to content

Instantly share code, notes, and snippets.

@DrBoolean
Created September 15, 2015 19:08
Show Gist options
  • Select an option

  • Save DrBoolean/3c7a71cbf5fae5af7d84 to your computer and use it in GitHub Desktop.

Select an option

Save DrBoolean/3c7a71cbf5fae5af7d84 to your computer and use it in GitHub Desktop.
IO reason
// 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'
@DrBoolean
Copy link
Author

Keeping it all to 1 unsafePerformIO on domReady is pretty nice. Also chaining many IO actions into 1 update is pleasant. Task and EventStream are both pure so most things (especially in node) don't need IO.

One issue is nested IO and 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment