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 Task = require('data.task'); | |
const Maybe = require('data.maybe'); | |
const { Reader, ReaderT } = require('ramda-fantasy'); | |
const R = require('ramda'); | |
const mysql = require('mysql'); | |
const request = require('request'); | |
const ReaderTask = Reader.T(Task); |
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 Prod = t => ({ | |
extract : () => t[1], | |
extend : f => Prod([t[0], f([t[0], t[1]])]), | |
map : f => Prod([t[0], f(t[1])]), | |
duplicate : () => Prod([t[0], Prod(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 Task = require('data.task'); | |
const { Reader, Maybe } = require('ramda-fantasy'); | |
const ReaderTask = Reader.T(Task); | |
const R = require('ramda'); | |
const express = require('express'); | |
const app = express(); | |
const MOCK_DB = { | |
5 : { |
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
/* | |
* According to the applicative functor laws, any applicative functor F must satisfy the composition law: | |
* | |
* pure (.) <*> F (+ 2) <*> F (* 2) | |
* === | |
* F (+ 2) <*> (F (* 2) <*> F 3) | |
* | |
* Let's see how we can show this with two Applicative Functors. Data.Task from folktale and Fluture. | |
* Data.Task implements the pre v1.0 spec of fantasy-land, while Fluture is up to date. | |
* |
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 tailRec = (f) => (a) => { | |
let v = f(a) | |
while (!v.done) { | |
v = f(v.value) | |
} | |
return v.value | |
} | |
const done = (v) => ({ value: v, done: true }) | |
const next = (v) => ({ value: v, done: false }) |
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
//take((e, a) => e+a*a, when(isEven, xs), when(isOdd, ys)) | |
//take((e, a) => e+a*a, [when(isEven, xs), ys]) | |
const R = require('ramda'); | |
// not lazy | |
const flatxprod = (x, y) => R.map(R.flatten, R.xprod(x, y)); | |
function * nprod(...args) { | |
function * rec(accum, xs) { |
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
/* | |
* examples - code for matchC is below | |
* to test: copy&paste into http://ramdajs.com/repl | |
*/ | |
function main() { | |
// its all good if all output lines have true in first tuple ;-) | |
const m1 = matchC('Hello') | |
.when('string', a => [true, a.toUpperCase()]) | |
.when('number', a => [false, a]) |
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 IO extends Monad { | |
constructor(fn) { | |
super(); | |
this.__value = fn; | |
} | |
static of(fn) { | |
const io = new IO(() => fn); | |
Object.freeze(io); | |
return io; |
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 fs = require('fs'); | |
const head = ([x, ...t]) => x; | |
const tail = ([x, ...t]) => t; | |
const compose = (f, ...rest) => (x) => | |
rest.length === 1 | |
? head(rest)(f(x)) | |
: compose(head(rest), ...tail(rest))(f(x)); |
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
https://www.youtube.com/watch?v=GquJWqNvEPw | |
Why does the 3rd world need longer to catch up? | |
- widespread internet use | |
- great democratisation of education taking place in the 3rd world (MOOC) | |
- 35$ notebook, down to 10$ within 2 years | |
- 3d printing of clothing | |
- educational system must change -> prices of higher education are way too high. industry must be transformed and equalised. | |
- cultures must adept as well |
NewerOlder