Commit 42be51d6 authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

Add typescript example.

parent 2a6eb8ee
enum ENil { NIL };
type EList = ENil | { node : ENode; next : EList };
type EDocument = { kind : 1 };
type EElement = { kind : 2; children : EList};
type EText = { kind : 9; isEmpty : () => boolean };
type ENode = EDocument | EElement | EText;
function isEmpty3 (x : EDocument) : true;
function isEmpty3 (x : { kind : 2; children : ENil }) : true;
function isEmpty3 (x : { kind : 2; children : { node : ENode; next : EList } }) : false;
function isEmpty3 (x : EElement) : boolean;
function isEmpty3 (x : EText) : boolean;
function isEmpty3 (x : ENode) : boolean {
if (x.kind == 1) {
return true;
} else if (x.kind == 2 && x.children == ENil.NIL) {
return true;
} else if (x.kind == 2) {
return false;
} else if (x.kind == 9) {
return x.isEmpty();
}
}
isEmpty3({ kind : 2, children : ENil.NIL });
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment