Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Better monad example #14

Closed
piranha opened this issue Nov 28, 2011 · 2 comments
Closed

Better monad example #14

piranha opened this issue Nov 28, 2011 · 2 comments
Labels

Comments

@piranha
Copy link
Collaborator

piranha commented Nov 28, 2011

Maybe it's worth it to have something better as an example for monad, to show why would you want them in JS. Something like this maybe:

type Request = {url: String, payload: String}

let ajaxRequest = {
  return: fn x = x
  bind: fn (x : Request) f =
    $.ajax x.url x.payload f
}

let v = (do ajaxRequest
  bind value = {url: '/url/', payload: 'stuff'}
  console.log value
  return value
)
@paulmillr
Copy link
Contributor

👍

@puffnfresh
Copy link
Owner

Very, very cool. 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants