Skip to content

Instantly share code, notes, and snippets.

View andrew-templeton's full-sized avatar

Andrew Templeton andrew-templeton

View GitHub Profile
@jimmydivvy
jimmydivvy / JavascriptIOMonadExample.js
Last active February 26, 2023 10:35
Simple IO Monad example in Javascript
class IO {
// We construct the IO type with a thunk/callback that returns the value when called
constructor( fn ){
this.fn = fn;
}
// IO doesn't do anything until we explicitly call it.
run(){
return this.fn();