declare module lib_trait { } /** * @author fenris */ declare module lib_trait { /** * @author fenris */ var _verbosity: number; /** * @author fenris */ var _logprefix: string; /** * @author fenris */ type type_domainparameters = { [key: string]: any; }; /** * @author fenris */ type type_domain = { kind: string; parameters?: type_domainparameters; }; /** * @author fenris */ type type_instance = { domain: type_domain; value: type_value; }; /** * @author fenris */ type type_handler = (domain_parameters?: type_domainparameters) => any; /** * @author fenris */ type type_facet_raw = { shape?: lib_shape.type_shape; description?: string; implementation?: Function; }; /** * @author fenris */ type type_condition = (attends: (trait_id: string, domain: type_domain) => boolean) => ((domain_parameters: type_domainparameters) => boolean); /** * @author fenris */ type type_typechecker = (value: any, shape: lib_shape.type_shape, logger: (message: string) => void) => boolean; /** * @author fenris */ function set_typechecker(typechecker: type_typechecker): void; /** * @author fenris */ function domain_instance(domain: type_domain, value: type_value): type_instance; /** * @desc adds a trait * @author fenris */ function define(trait_id: string, variable_conditions: { [variable_name: string]: Array; }, facets_raw: { [facet_name: string]: type_facet_raw; }): void; /** * @desc adhoc binding * @author fenris */ function attend(trait_id: string, domain_kind: string, bindings: { [variable_name: string]: lib_shape.type_shape; }, handlers: { [facet_name: string]: type_handler; }, condition?: type_condition): void; /** * @desc calls a facet from a trait according to a given domain * @author fenris */ function call(trait_id: string, facet_name: string, domain: type_domain, check?: boolean): any; /** * @author fenris */ function explain(trait_id: string): string; /** * @author fenris */ function explain_all(): string; } /** * @author fenris */ declare module lib_trait { /** * @desc the ability to check for equality with another element of the same domain * @author fenris */ function define_collatable(): void; /** * @author fenris */ function _collate(instance: any, other: any, domain?: { kind: string; }): boolean; } /** * @author fenris */ declare module lib_trait { /** * @desc the ability to compare with another element of the same domain for determining if the first is "smaller than or equal to" the latter * @author fenris */ function define_comparable(): void; /** * @author fenris */ function _compare(instance: any, other: any, domain?: { kind: string; }): boolean; } /** * @author fenris */ declare module lib_trait { /** * @desc the ability to create an exact copy * @author fenris */ function define_clonable(): void; /** * @author fenris */ function _clone(instance: any, domain?: { kind: string; }): any; } /** * @author fenris */ declare module lib_trait { /** * @desc the ability to generate a string out of the element, which identifies it to a high degree * @author fenris */ function define_hashable(): void; /** * @author fenris */ function _hash(instance: any, domain?: { kind: string; }): string; } /** * @author fenris */ declare module lib_trait { /** * @desc the ability to map the element to a textual representation (most likely not injective) * @author fenris */ function define_showable(): void; /** * @author fenris */ function _show(instance: any, domain?: { kind: string; }): string; }