# Standard Set type?

**URL:** https://community.haxe.org/t/standard-set-type/1845
**Category:** Haxe
**Created:** [June 27, 2019, 7:20pm UTC](https://community.haxe.org/t/standard-set-type/1845 "2019-06-27T19:20:12Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![Kallekro](https://community.haxe.org/user_avatar/community.haxe.org/kallekro/32/1989_2.png) [@Kallekro](https://community.haxe.org/u/Kallekro)
#### Post date: [September 30, 2022, 1:22pm UTC](https://community.haxe.org/t/standard-set-type/1845/10 "2022-09-30T13:22:00Z")

</div>

I tried to create an abstract set based on a Map with generic value as you suggest.

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

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

	@:from static public function fromArray(arr:Array<Int>) {
        final newSet = new Set();
        for (val in arr) newSet.push(val);
        return newSet;
    }

    @:to public function toArray<T>() {
        return [for (val in this.keys()) val];
    };
}

```

But there’s an issue, when trying to create an instance of this type I get the following error:  
`Set.hx:3: characters 16-34 : Abstract haxe.ds.Map has no @:to function that accepts haxe.IMap<Set.T, Bool>`

I think it’s related to Map not supporting all types, e.g. Float.

Do you have a suggestion to solve this issue?  
I can just create a non-generic set, but it would be pretty nice to have a generic version.

---

_[View the full topic](https://community.haxe.org/t/standard-set-type/1845)._
