# @:from interface

**URL:** https://community.haxe.org/t/from-interface/2850
**Category:** Haxe
**Created:** [January 15, 2021, 6:12pm UTC](https://community.haxe.org/t/from-interface/2850 "2021-01-15T18:12:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Alias](https://avatars.discourse-cdn.com/v2/letter/a/a88e4f/32.png) [@Alias](https://community.haxe.org/u/Alias)
#### Post date: [January 15, 2021, 6:12pm UTC](https://community.haxe.org/t/from-interface/2850/1 "2021-01-15T18:12:02Z")

</div>

Hello!

I’m playing around with Haxe abstracts and am having a lot of fun with them. However, they don’t play nice with interfaces, or maybe i’m just not getting it!

Here is some example code. The @:from implicit cast does not play well with interfaces. c\_loveshaxe will not compile!? Is there anything I can do to make it compile?

I’m using Haxe/HL but I’m assuming that it’s a generic thing.

Many thanks for any help on this.

```haxe
// an interface
interface LovesHaxe {
    public var a: Int;
}

// a test class
class Test implements LovesHaxe {
    public var a: Int = 0;

    public function new(a: Int = 0) {
        this.a = a;
    }
}

// abstract implementation
class ContainerImpl<T> {
    public var value(default, null): Null<T>;

    public function new(value: Null<T> = null) {
        set(value);
    }

    public function set(value: Null<T>) {
        this.value = value;
    }
}

// our abstract
@:forward
abstract Container<T>(ContainerImpl<T>) from ContainerImpl<T> {

    public inline function new(value: Null<T> = null) {
        this = new ContainerImpl<T>(value);
    }

    @:from static function fromT<T>(value: Null<T>): Container<T> {
        return new Container(value);
    }
}

class SomeClass {
    public static function main() {
        var c_int: Container<Int> = 10; // good
        var c_test: Container<Test> = new Test(10); // good!
        var c_loveshaxe: Container<LovesHaxe> = new Test(10); // bad! Container dos not love haxe!
    }
}

```
