A different question might be: why do you want it to be type stable at all?
One would presume that f(d) is more CPU intensive than for f in fs.
And running your model even more so than that.
It seems like premature optimization to me. Though, of course, that might be because of your simplified example. And in different situations it would be desirable.
I run large analytics and I never worry about type stability of the setup because the analysis dominates.