Skip to content

Instantly share code, notes, and snippets.

@dumconstantin
Last active July 26, 2016 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dumconstantin/de21de8aa0791db37f66228d641090a6 to your computer and use it in GitHub Desktop.
Save dumconstantin/de21de8aa0791db37f66228d641090a6 to your computer and use it in GitHub Desktop.
For Medium article
(function(exports) {
var Functor = function (map) {
this.map = map;
};
var map = function (dict) {
return dict.map;
};
exports["Functor"] = Functor;
exports["map"] = map;
})(PS["Data.Functor"] = PS["Data.Functor"] || {});
(function(exports) {
"use strict";
var Apply = function (functor, apply) {
this.functor = functor;
this.apply = apply;
};
var apply = function (dict) {
return dict.apply;
};
exports["Apply"] = Apply;
exports["apply"] = apply;
})(PS["Control.Apply"] = PS["Control.Apply"] || {});
(function(exports) {
var Control_Apply = PS["Control.Apply"];
var Data_Functor = PS["Data.Functor"];
var Just = (function () {
function Just(value0) {
this.value0 = value0;
};
Just.create = function (value0) {
return new Just(value0);
};
return Just;
})();
var Nothing = (function () {
function Nothing() {
};
Nothing.value = new Nothing();
return Nothing;
})();
var functorMaybe = new Data_Functor.Functor(function (v) {
return function (v1) {
if (v1 instanceof Just) {
return new Just(v(v1.value0));
};
return Nothing.value;
};
});
var applyMaybe = new Control_Apply.Apply(function () {
return functorMaybe;
}, function (v) {
return function (v1) {
if (v instanceof Just) {
return Data_Functor.map(functorMaybe)(v.value0)(v1);
};
if (v instanceof Nothing) {
return Nothing.value;
};
};
});
exports["Just"] = Just;
exports["Nothing"] = Nothing;
exports["functorMaybe"] = functorMaybe;
exports["applyMaybe"] = applyMaybe;
})(PS["Data.Maybe"] = PS["Data.Maybe"] || {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment