Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 806 Bytes

tdnr.md

File metadata and controls

29 lines (22 loc) · 806 Bytes

Type-Directed Name Resolution (TDNR)

There was a proposal to add TDNR to Haskell. This is REALLY interesting for Silicon because this would really sell the language and set it apart from being too FP or too OOP.

@mod int = (
    @fn toString:string value:int;
);

@mod bool = (
    @fn toString:string value:bool;
);

#toString x;
// ERROR: ambigous function call.
// no function overloading.

// fully-qualified name
int::toString x; // correct
bool::toString x; // correct

// Type-Defined Name Resolution
// if X is of type int then it'll resolve to int::toString
// if X is of type bool then it'll resolve to bool::toString
#x.toString;

#5.toString; // "5"
#true.toString; // "true"