Standard Set type?

Late response, but if anyone else stumbles in here from search:

The easiest way is to add a type constraint so that the compiler knows that it should use an ObjectMap:

abstract Set<T:{}>(Map<T, Bool>) {
	public function new() {
		this = new Map<T, Bool>();
	}

	public function add(val:T) this[val] = true;
	public function remove(val:T) this.remove(val);
	public function contains(val:T):Bool return this.exists(val);
	public function toString() return toArray().toString();

	@:from
	static public function fromArray<T:{}>(arr:Array<T>) {
		final newSet = new Set();
		for (val in arr) newSet.add(val);
		return newSet;
	}
	@:to
	public function toArray() {
		return [for (val in this.keys()) val];
	};
}

The non-easiest way is to borrow @:multiType and @:from syntax from haxe.ds.Map itself. Here’s a gist.