Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var samples =
[ ' do var <- readTVar'
, 'do foo'
, 'main = do let x = do { foo }'
, 'main = do let x = do foo'
, 'main = foo $ do '
];
for (var i in samples) {
var line = samples[i];
if (line.search(/(\s*do\s+)/) !== -1) {
var lastDo = line.lastIndexOf("do");
var rest = line.substring(lastDo+2);
if (rest.trim() === "") {
console.log("No match: " + line);
continue;
}
if (rest.indexOf("{") !== -1) {
lastDo = line.substring(0, lastDo).lastIndexOf("do");
}
var ident = Array(lastDo+1+3).join(" ");
console.log(line);
console.log(ident + "^");
console.log("--------------------------");
} else {
console.log("No match: " + line);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment