Skip to content

Instantly share code, notes, and snippets.

@back2dos
back2dos / ArrayRead.hx
Last active September 29, 2017 01:02 — forked from nadako/ArrayRead.hx
Recursive read-only type generator for JSON structures (based on @:genericBuild)
@:forward(map, filter, copy, slice)
abstract ArrayRead<T>(Array<T>) from Array<T> to Iterable<T> {
@:arrayAccess inline function get(i:Int):T return this[i];
public var length(get,never):Int;
inline function get_length() return this.length;
}
enum Process<O> {
Emit(head:O,tail:Process<O>);
Held(ft:Future<Process<O>>);
Halt(e:Null<Error>);
}
typedef InOut<In, Out> = Process<Either<Callback<In>, Out>>;
@back2dos
back2dos / Signal.hx
Last active December 23, 2015 09:19
#if macro
import haxe.macro.Context;
import haxe.macro.Expr;
#end
abstract Signal<T>(Array<T>)
{
public inline function new()
{
this = [];
@back2dos
back2dos / Main.hx
Created March 12, 2012 11:08
Fluent tag interface for haxe
package ;
using Tag;
class Main
{
static function main()
{
var t = "div".tag().att("id", "container")
.child("a".tag().att("href", "http://www.haxe.org")
@back2dos
back2dos / MacroLambda.hx
Created February 24, 2012 17:21 — forked from jdonaldson/MacroLambda.hx
MacroLambda: Automatically return new lists or arrays depending on the map argument type.
import haxe.macro.Expr;
import haxe.macro.Context;
class MacroLambda
{
public static function main(): Void
{
trace('Hello World');