Typing

This is an implementation, not an answer to my questions.
It looks stupid to perform constant folding on value (it is what is done in your code) to compute the type and not replacing it in the code.