scala - heterogenous mapping, dependent types at compile time -
trying use this trick, miles sabin, create function accepts parameter of set of predefined types . val bool = boolean val timestamp = new timestamp(date.gettime()) val str = "my string" and following should pass @ compile time takevalue(bool) takevalue(timestamp) takevalue(str) but where takevalue should fail takevalue(someintvalue) if implicit type int isn't defined.and failure @ compile time. trait myconv[k] { type v; def convert: anyref => v } def imakeconv[v0](con: anyref => v0) = new myconv[con.type] { override type v = v0 val convert = con } def takevalue(value:anyref)(implicit conv :myconv[value.type]) : \/[throwable,conv.v] = \/.fromtrycatch(conv.convert(value)) and implicit val strany = imakeconv((x:any) => x.tostring) then want takevalue(str) work @ compile time takevalue(someintvalue) fail @ compile time since there isn't appropriate implicit defined it. want limit(at compile time) type of types takevalue c