This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const daggy = require("daggy"); | |
const { Loop, Done } = daggy.taggedSum("Loop", { | |
Loop: ["b"], | |
Done: ["a"] | |
}); | |
Array.empty = () => []; | |
const Pair = T => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Promise = require("fantasy-promises"); | |
const daggy = require("daggy"); | |
//- Regular `compose` - old news! | |
//+ compose :: (b -> c) | |
//+ -> (a -> b) | |
//+ -> a -> c | |
const compose = f => g => x => f(g(x)); | |
//- `chain`-sequencing `compose`, fancily |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const daggy = require("daggy"); | |
const { uncurryN } = require("wi-jit"); | |
Array.prototype.empty = () => []; | |
const Sum = daggy.tagged("Sum", ["value"]); | |
Sum.prototype.concat = function(that) { | |
return Sum(this.value + that.value); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { tagged } = require("daggy"); | |
const Pair = tagged("Pair", ["_1", "_2"]); | |
//+ data Store p s = Store (p -> s) p | |
const Store = tagged("Store", ["lookup", "pointer"]); | |
Array.prototype.equals = function(that) { | |
return ( | |
this.length === that.length && |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Left, Right } = require("fantasy-eithers"); | |
const daggy = require("daggy"); | |
Function.prototype.map = function(f) { | |
return x => f(this(x)); | |
}; | |
//- Where everything changes... | |
const login = user => (user.name == "Tom" ? Right(user) : Left("Boo")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DatePicker extends React.PureComponent { | |
constructor(props) { | |
super(props) | |
this.picker = PickerModel.create({ | |
calendar: { | |
value: props.defaultValue, | |
min: props.min, | |
max: props.max, | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetch from 'isomorphic-fetch' | |
const setupRequestOptions = (options = {}, overrideMethod) => { | |
if (overrideMethod) options.method = overrideMethod | |
if (!options.headers) options.headers = {} | |
options.credentials = 'same-origin' | |
return options | |
} | |
const setupJsonRequestOptions = (options, overrideMethod) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import R from 'ramda' | |
const mergePlan = (x, y) => { | |
if(Array.isArray(x) && Array.isArray(y)) { | |
return R.uniq(R.concat(x, y)); | |
} | |
if(typeof x === 'object' && typeof y === 'object'){ | |
return R.mergeWith(mergePlan, x, y) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import R from 'ramda' | |
const defaultConfig = (config = {}) => { | |
const { | |
localStorage: storage = { removeItem: R.F }, | |
__APP_VERSION__: version = '', | |
} = __BROWSER__ ? window : {} | |
const namespace = 'my-cool-app' | |
const appName = `${namespace}.v${version}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import R from 'ramda' | |
const runTask = R.curry((taskList, deadline) => { | |
while ((deadline.timeRemaining() > 0 || deadline.didTimeout) && taskList.length) { | |
const task = taskList.shift() | |
task() | |
} | |
if (taskList.length) { |