A functional compile-to-JS language for writing beautiful command-line interfaces.
- Functional (closures, first-class functions, purity)
[ | |
a: 1 | |
, b: 2 | |
, c: 3 | |
] | |
[ a: 1 | |
, b: 2 | |
, c: 3 | |
] |
function attributes(xs, name) { | |
return is_element(xs)? xs.getAttribute(name) | |
: is_array(xs)? xs.map(attributes) | |
: is_sequence(xs)? map(xs, attributes) | |
: /* otherwise */ raise(TypeError('Not supported.')) | |
} | |
// vs | |
function attributes(xs, name) { |
# Algorithm W (Damas-Hindley-Milner) in LiveScript. | |
# By Paul Miller (paulmillr.com), Public domain. | |
# | |
# Based on Robert Smallshire's [Python code](http://bit.ly/bbVmmX). | |
# Which is based on Andrew's [Scala code](http://bit.ly/aztXwD). | |
# Which is based on Nikita Borisov's [Perl code](http://bit.ly/myq3uA). | |
# Which is based on Luca Cardelli's [Modula-2 code](http://bit.ly/Hjpvb). | |
# Something like that. | |
prelude = require './prelude' |
uses html; | |
uses prelude; | |
let style-sheets { |...xs| | |
map xs { |x| link href: x/url rel: x/kind type: "text/css" }; | |
}; | |
let search-panel { | |
uses jumper-skirt as jsk; |
On module systems in general, and AMD/CommonJS in particular: simplicity, community, etc.
On the performance implications of real-world applications with Promises/A+ for abstracting over asynchronous computations.
How command line interfaces usually suck beyond anything, and what we could do to get back the UNIX philosophy and more simplicity.
A short introduction to programming language theory and programming language design. Parsing, semantics, formal syntaxes, interpreters, optimizers and compilers.
module Sorting where | |
-- See https://www.twanvl.nl/blog/agda/sorting | |
open import Level using () renaming (zero to ℓ₀;_⊔_ to lmax) | |
open import Data.List hiding (merge) | |
open import Data.List.Properties | |
open import Data.Nat hiding (_≟_;_≤?_) | |
open import Data.Nat.Properties hiding (_≟_;_≤?_;≤-refl;≤-trans) | |
open import Data.Nat.Logarithm | |
open import Data.Nat.Induction |
A delayed computation is a function that will do some computation when called. Because of the delayed nature the computation may be asynchronous so the function takes a callback.
Note: the term "delayed computation" is just a temporary name so we can talk about this idea, I do not recommend using this name as it's a) confusing and b) this concept is hard to name.
// data comes from here http://stat-computing.org/dataexpo/2009/the-data.html | |
// download 1994.csv.bz2 and unpack by running: cat 1994.csv.bz2 | bzip2 -d > 1994.csv | |
// 1994.csv should be ~5.2 million lines and 500MB | |
// importing all rows into leveldb took ~50 seconds on my machine | |
// there are two main techniques at work here: | |
// 1: never create JS objects, leave the data as binary the entire time (binary-split does this) | |
// 2: group lines into 16 MB batches, to take advantage of leveldbs batch API (byte-stream does this) | |
var level = require('level') |
# will suspend on every function call (very proof of concept, | |
# it will be really easy to get access to local variables, a | |
# full stack, and even live evaluate within any closure) | |
% node test.out.js | |
[suspended] foo() | |
> c | |
[suspended] bar(x) | |
> c | |
[suspended] bar(i - 1) |