-
Notifications
You must be signed in to change notification settings - Fork 0
/
poc.js
40 lines (32 loc) · 823 Bytes
/
poc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const __tube_lang__ = require('./build/src/main.js');
const { compile } = __tube_lang__;
const implementationWorld = `
const state = () => ({ A: { B: { a: 1, b: 2, c:3, d:4 } } })
const getA = ({ A }) => A
const getB = ({ B }) => B
const sumB = v => state => ({ ...state, b: state.b + v })
const sumBFour = sumB(4)
const isLengthGreaterThan = v => state => state.length > v
const shift = state => state.slice(1)
const pop = state => state.slice(0, state.length - 1)
const divide = times => state => state / times
const first = state => state[0]
`;
const declarativeWorld = compile(`
-> extractAB
getA
getB
state
extractAB
< console.log >
Object.values
isLengthGreaterThan 2
: shift
: pop
first
< console.log >
::toString
divide by 2
< console.log >
`);
eval(implementationWorld + declarativeWorld);