Skip to content

Support GADT? #83

@kevinresol

Description

@kevinresol

Currently the following snippet will fail with:
src/tink/macro/Sisyphus.hx:81: characters 22-57 : Type not found : T

class Main {
	static function main() {
		trace(stringify(VInt(TInt8, 0)));
	}
	
	static function parse<T>(v:String) {
		return tink.Json.parse((v:CValue<T>));
	}
	static function stringify<T>(v:CValue<T>):String {
		return tink.Json.stringify(v);
	}
}

enum CType<T> {
	TUInt8:CType<Int>;
	TInt8:CType<Int>;
	TBool:CType<Bool>;
	TArray<V>(type:CType<V>, size:Int):CType<Array<V>>;
}

enum CValue<T> {
	VInt(type:CType<Int>, v:Int):CValue<Int>;
	VBool(v:Bool):CValue<Bool>;
	VArray<V>(type:CType<Array<V>>, v:Array<V>):CValue<Array<V>>;
}

Changing the signature of stringify to the following will make the error more epic:
static function stringify(v:CValue<Dynamic>):String

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions