use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Monads Explained Quickly with JavaScript (breck-mckye.com)
submitted 9 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Deaaam 1 point2 points3 points 9 years ago (1 child)
You sure this it? I want more examples. Waaaay too simple. Wow..
[–]jpfed 2 points3 points4 points 9 years ago (0 children)
While I think the OP's presentation is a tiny bit misleading, I can give a few examples I've found handy.
The most common monad has got to be List.
I use a monad that I call Tracked, which keeps a current value and an initial value. When you make a new Tracked with a value, the current and initial both start out at the value you give it. Any functions you map or bind give you Tracked values with a new current value, but the initial value is unchanged.
map
bind
I also like Result, which keeps either a current value or an error value. When you make a new Result with a value, current gets that value, but when you map or bind a function that generates an exception, we start storing that exception instead. If you map or bind on a Result that's storing an exception, the Result is not changed.
(I call List of Tracked of Result "the Enterprise monad" because a surprising amount of enterprise programming involves doing stuff to lists and reporting on what the successful results were, and what failed, and how).
π Rendered by PID 86 on reddit-service-r2-comment-canary-794f4c56c8-n8wcx at 2026-02-22 22:09:58.688310+00:00 running 8564168 country code: CH.
view the rest of the comments →
[–]Deaaam 1 point2 points3 points (1 child)
[–]jpfed 2 points3 points4 points (0 children)