Skip to content

Instantly share code, notes, and snippets.

View DrBoolean's full-sized avatar

Brian Lonsdorf DrBoolean

View GitHub Profile
@DrBoolean
DrBoolean / pointfree folktale.js
Last active April 14, 2016 14:14
Pointfree fantasy working with folktale's either
require("pointfree-fantasy").expose(global);
var curry = require("lodash.curry");
var fs = require("fs");
var Either = require("data.either");
// HELPERS
// ============
var add = curry(function(x,y) { return x + y });
@DrBoolean
DrBoolean / traversable foldable.js
Last active February 9, 2017 12:24
Traversable/Foldable of/empty issue
Nothing.prototype.traverse = function(f) {
return ?.of(Nothing()); //how to get pure if we can't call f?
}
Just.prototype.traverse = function(f) {
return f(this.val).map(Just);
}
Nothing.prototype.foldl = function(f) {
return ?.empty() // same prob as traverse - need to run f() to get correct empty
};
Just.prototype.foldl = function(f, acc) {
var Option = require('fantasy-options')
var Some = Option.Some;
var None = Option.None;
var Compose = function(x){
this.val = x;
}
Compose.prototype.map = function(f){
return new Compose(this.val.map(function(u){return u.map(f); }));
@DrBoolean
DrBoolean / NEL.js
Last active August 29, 2015 14:06
Non empty list comonad in js
var _One = function(v) {
this.value = v;
};
var _Many = function(v, vs) {
this.value = v;
this.tail = vs;
};
var One = function(x) { return new _One(x); };
@DrBoolean
DrBoolean / Coyoneda.js
Created March 4, 2015 02:33
Coyoneda
// helpers
var compose = function(f,g) {
return function(x) {
return f(g(x))
}
}
var id = function(x) { return x }
@DrBoolean
DrBoolean / comonad_wrapper.js
Created August 18, 2015 18:11
Lazy wrap/value comonad from lodash/underscore
// Helpers
//=================
var compose = function(f,g) {
return function(x) {
return f(g(x))
}
}
var id = function(x) { return x }
@DrBoolean
DrBoolean / app_1.js
Last active August 26, 2015 17:17
Blog post about salesforce design system + react
var React = require('react');
var Notification = require('./notification');
var App = React.createClass({
render: function() {
return (
<div>
<Notification />
</div>
@DrBoolean
DrBoolean / app_2.js
Created August 25, 2015 22:52
Blog post about salesforce design system + react 2
var App = React.createClass({
render: function() {
return (
<div>
<Notification>
<h2 className="slds-text-heading--small">Beware of the Trash Dragons!</h2>
</Notification>
</div>
);
@DrBoolean
DrBoolean / notification_1.js
Last active August 26, 2015 17:58
Blog post about salesforce design system + react 3
var React = require('react');
var Notification = React.createClass({
render: function() {
return <div />;
}
}
module.exports = Notification;
@DrBoolean
DrBoolean / notification_2.js
Last active August 26, 2015 17:17
Blog post about salesforce design system + react 4
render: function() {
return (
<div className="slds-notify-container">
<div className="slds-notify slds-notify--alert" role="alert">
<span className="slds-assistive-text">info</span>
<button className="slds-button slds-notify__close slds-icon--small">
<svg aria-hidden="true" className="slds-button__icon slds-button__icon--inverse" dangerouslySetInnerHTML={{__html:'<use xlink:href="/assets/icons/action-sprite/svg/symbols.svg#close"></use>'}}>
</svg>
<span className="slds-assistive-text">Close</span>
</button>