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
syntax foo = function(ctx) { | |
let result = #`foo(`; | |
result = result.concat(#`)`); | |
return result; | |
}; |
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
title file |
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
function test(f) { | |
var counter = 10000000; | |
performance.clearMarks(); | |
performance.mark('StartTest'); | |
for(var i = counter; i > 0; --i) { | |
f(); | |
} | |
performance.mark('EndTest'); | |
var marks = performance.getEntriesByType('mark'); | |
return marks[1].startTime-marks[0].startTime; |
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 t = Table.of({a:1, b:2, c:3}); | |
const t2 = Table.of({a:4, d:5}); | |
const t3 = t.concat(t2).concat(Table.empty()); | |
t3 // Table {a: 4, b: 2, c: 3, d: 5} | |
t3.head() // Object {a: 4, d: 5} | |
t3.tail() // Table {a: 1, b: 2, c: 3} | |
t3.append({b:6, e:7}) // Table {a: 4, b: 6, c: 3, d: 5, e: 7} | |
t3.reduce(x => x * x) // Object {a: 16, b: 4, c: 9, d: 25} | |
Table.empty().alt(t3) // t3 |
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 alias = prefix => T => { | |
const getKeys = o => Object.keys(o) | |
.filter(k => k.startsWith(prefix+'/')) | |
.map(k => k.split('/')[1]); | |
const scaryMutateObject = o => getKeys(o).forEach(k => o[k] = o[prefix+'/'+k]); | |
scaryMutateObject(T); | |
scaryMutateObject(T.prototype); | |
// I'M RETURNING UNDEFINED!!! |
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
// Likely VERY inefficient port of Data.Trie | |
function Trie(a) { | |
// could null be a valid value? if so, we can't use S.toMaybe | |
this.value = S.toMaybe(a); | |
this.children = {}; | |
this.ks = Object.freeze(this.value.isNothing ? [] : ['']); | |
}; | |
/* Setoid */ | |
// Trie a ~> Trie a -> Bool |
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
function Unit() { return Unit; } | |
function Pair(fst, snd) { | |
'use strict'; | |
if(this === void 0) return new Pair(fst, snd); | |
this.fst = fst; | |
this.snd = snd; | |
} | |
Pair.prototype.map = //... | |
//... |
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 { class, interface, implements } from 'sweet-interfaces'; | |
const constant = x => _ => x; | |
const identity = x => x; | |
const flip = f => (a, b) -> f(b, c); | |
interface Setoid { | |
// eq :: Setoid a => a ~> a -> Boolean | |
eq(b) { return this === b; } | |
} |
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
-- Potential solutions for multiple backend porting issues | |
-- 1. Optional PS implementation for optional foreign imports | |
-- JS has an implementation, Erlang would export bar instead | |
module Foo (foo) where | |
-- import `fooImpl` if it's provided by the host implementation | |
optional foreign import foo :: Number -> Number -> Number | |
-- define it otherwise |
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 { Right, Future, pipe, curry2, ifElse, isNotNil, memoize, chain, map } from "../fp" | |
// mssql.js | |
import sql from "mssql" | |
const createPoolAsync = memoize(connectionString => | |
new Future( ( reject, resolve ) => { | |
const pool = new sql.ConnectionPool( | |
connectionString, | |
ifElse( isNotNil, reject, () => resolve( pool ) ) | |
); |
OlderNewer