Skip to content

Instantly share code, notes, and snippets.

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>>;
var run = true;
Thread.create(function () {
Sys.getChar(true);
run = false;
});
while (run) {
Sys.sleep(.5);
println('yay');//assume this would block until the other side reads in fact
@back2dos
back2dos / UntypedNew.hx
Created November 19, 2014 12:41
Support for untyped new.
package ;
#if macro
import haxe.macro.Compiler;
import haxe.macro.Context;
import haxe.macro.Expr;
using haxe.macro.Tools;
#end
@back2dos
back2dos / ClassList.hx
Last active September 3, 2023 12:18
Store all class names for runtime use.
package ;
#if macro
import haxe.macro.Context.*;
using haxe.macro.Tools;
#end
class ClassList {
static var NAME = 'ClassList';//must be the fully qualified name of this class
macro static function build() {
@back2dos
back2dos / results.txt
Created January 22, 2015 09:34
Top 100 Haxelibs by download
+-----------+----------------------+
| downloads | name |
+-----------+----------------------+
| 78260 | openfl |
| 57649 | lime |
| 50236 | openfl-samples |
| 49287 | hxcpp |
| 43047 | lime-tools |
| 41134 | openfl-native |
| 40236 | actuate |
@back2dos
back2dos / Main.hx
Created June 1, 2015 07:57
Macro context vs. output context
//Original source code:
class Main {
#if !macro
static function main() {
test();
}
#end
macro static function test() {
@back2dos
back2dos / AnonEnum.hx
Created June 17, 2015 15:49
Anonymous enums \o/
#if macro
import haxe.macro.Expr;
import haxe.macro.Type;
import haxe.macro.Context.*;
#else
@:genericBuild(AnonEnum.build())
#end
class AnonEnum<Const> {
macro static function build():Type {
@back2dos
back2dos / Main.h
Last active August 29, 2015 14:28
Out args for hxcpp.
#ifndef INCLUDED_Main
#define INCLUDED_Main
#ifndef HXCPP_H
#include <hxcpp.h>
#endif
HX_DECLARE_CLASS0(Main)
@back2dos
back2dos / Forever.hx
Created January 4, 2016 16:24
Run stuff forever.
package;
class Forever {
static function main() {
var args = Sys.args();
while (true) {
Sys.command(args[0], args.slice(1));
Sys.sleep(.25);
}
}
@back2dos
back2dos / TreeWalker.hx
Created January 27, 2016 16:03
Walk trees.
import js.html.Element;
interface TreeWalker<T, Cls> {
function attr(target:T, name:String):String;
function hasClass(target:T, cls:Cls):Bool;
function parent(target:T):Null<T>;
function prev(target:T):Null<T>;
function next(target:T):Null<T>;
function firstChild(target:T):Null<T>;
}