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
// Utils | |
const fantasyConcat = (semiOne, semiTwo) => { | |
if ( | |
semiOne.instances && | |
semiTwo.instances && | |
semiOne.instances.includes("Semigroup") && | |
semiTwo.instances.includes("Semigroup") | |
) | |
return semiOne.concat(semiTwo); |
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 NOTHING = {}; | |
const safeProperty = (obj, propertyName) => (obj[propertyName] ? obj[propertyName] : NOTHING); | |
const recurProperties = (obj, ...propertyNames) => | |
propertyNames.reduce( | |
(accValue, currentProperty) => | |
accValue[currentProperty] ? accValue[currentProperty] : NOTHING, | |
obj | |
); |
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 jsc = require("jsverify"); | |
// Write a function that: | |
// Takes an array of strings | |
// Removes all instances of a dash character (-) | |
// Makes sure concatenating the strings will result in a string | |
// shorter than 200 characters | |
// (by removing all extra fluff from the tail) | |
// Makes all strings lowercase | |
// Returns an array of the resulting strings. |
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 jsc = require("jsverify"); | |
// Necessary Utils | |
const id = x => x; | |
const compose = (...fns) => x => fns.reduceRight((v, f) => f(v), x); | |
// Functor Properties | |
const functorIdentity = f => f.fmap(id).toString() === f.toString(); |
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 Nothing = () => ({ | |
isJust: () => false, | |
fold: (b, f) => b, | |
inspect: () => `Nothing` | |
}); | |
const Just = x => ({ | |
isJust: () => true, | |
fold: (b, f) => f(x), | |
inspect: () => `Just${x}` |