typed_value function

Transform a value according to its type