User loginNavigation |
Languages with first order types and partial evaluationI'm seeking languages which implement following features: 1) Types are first class citizens and can be treated as ordinary values The idea I try to follow can be best described using a little example. Say you have typed variables x:even, y:odd which are not yet bound by values. One can state explicit type rules for an operation add like this: add(x:even, y:even) -> even add(x:odd, y:even) -> odd ... and write down any kind of permutation of argument types. But instead one might compute the types using a function: type(x) = case mod(x,2) of 1 -> odd 0 -> even else `type(x) -- returns unevaluated expression type(x) with mod(x+y,k:int) = mod(mod(x,k)+mod(y,k),k) -- use pattern matching for decomposition mod(x*y,k:int) = mod(mod(x,k)*mod(y,k),k) mod(x:even,2) = 0 mod(x:odd,2) = 1 Now one can compute z = x*x+y*y+3 and deal with z as a variable of known type and perform type guarded simplifications. Maybe someone has a pointer where to find reading material ( or even language implementations ) that deal with related ideas? By Kay Schluehr at 2006-12-06 13:22 | LtU Forum | previous forum topic | next forum topic | other blogs | 6775 reads
|
Browse archives
Active forum topics |
Recent comments
22 weeks 6 days ago
22 weeks 6 days ago
22 weeks 6 days ago
45 weeks 19 hours ago
49 weeks 2 days ago
50 weeks 6 days ago
50 weeks 6 days ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago