Skip to content

Instantly share code, notes, and snippets.

@Fedjmike
Fedjmike / value.c
Created September 15, 2015 22:01
value.c with a ProgramInvocation kind for lazy invocation
#include "value.h"
#include <stdio.h>
#include <unistd.h>
#include <gc.h>
#include <common.h>
#include "sym.h"
#include "runner.h"
#include "invoke.h"
@Fedjmike
Fedjmike / runner.c
Created September 15, 2015 21:59
runner.c that separates the runner entry point from the AST handler
#include "runner.h"
#include <gc.h>
#include "dirctx.h"
#include "sym.h"
#include "ast.h"
#include "type.h"
#include "value.h"
@Fedjmike
Fedjmike / for_dir.h
Last active August 26, 2015 04:58
A macro for iterating over the contents of a directory.
#include <dirent.h>
#define for_dir(entry, dirname, continuation) \
do { \
DIR* for_dir_dir__ = opendir(dirname); \
for (struct dirent* (entry); \
((entry) = readdir(for_dir_dir__));) { \
continuation \
} \
closedir(for_dir_dir__); \

type tree: {payload: int, void | {l, r: tree*}}

fun treePrint: (root: tree*) -> void {

}

Algebraic data types

  • Declare using named case labels inside struct
  • Fields declared before a case are common to all cases