View helpers.js
import * as H from 'sweet.js/helpers' for syntax;
syntax m = ctx => {
let v = ctx.next().value;
if (H.isIdentifier(v, 'foo') {
return H.fromString(v, 'bar');
}
return H.fromString(v, 'baz');
}
m foo; // expands to 'bar'
View modules_for_syntax.js
// log.js
'lang sweet.js';
export function log(msg) {
console.log(msg);
}
// main.js
import { log } from './log.js' for syntax;
syntax m = ctx => {
log('doing some Sweet things');
View modules.js
// foo.js
'lang sweet.js';
export syntax m = // ...
// main.js
'lang sweet.js';
import { m } from './foo';
m // ...
View expansion.js
fetch("/foo.json").then(resp => {
return resp.json();
}).then(json => {
return processJson(json);
});
View operators.js
operator >>= left 1 = (left, right) => {
return #`${left}.then(${right})`;
}
fetch('/foo.json') >>= resp => { return resp.json() }
>>= json => { return processJson(json) }
View getlocation.js
// the web is crazy
// http://stackoverflow.com/questions/736513/how-do-i-parse-a-url-into-hostname-and-path-in-javascript
function getLocation(href) {
var location = document.createElement("a");
location.href = href;
// IE doesn't populate all link properties when setting .href with a relative URL,
// however .href will return an absolute URL which then can be used on itself
// to populate these additional fields.
if (location.host == "") {
location.href = location.href;
View gist:9d216aee2442d737df35
let function = macro {
rule { $name (callback $arg $rest ...) { $body ... } } => {
function $name ($arg $rest ...) {
$body ...
}
}
}
function foo(callback cb, x, y, z) {
cb(x + y + z);
View stxparm.md

Syntax parameters allow us to play around with hygiene in a principled fashion.

stxParam it = function() { throw new Error("must be rebound"); };

let aif = macro {
    rule { ($cond ...) { $body ...} } => {
	var it_inner  = $cond ...;
	if (it_inner) {
View gist:8ba94ee2e5c8649f7c37
### Keybase proof
I hereby claim:
* I am disnet on github.
* I am disnet (https://keybase.io/disnet) on keybase.
* I have a public key whose fingerprint is 1CCB B2BE 266F 8706 733F C4A7 07DF 8A2D E8B1 D193
To claim this, I am signing this object: