Using the mechanic employed by the scala plugin I linked to[1], dofib would be annotated with pure(argumentProvider). dofib itself is pure however, at each call site, it has the effect of its argument for that call. This is consistent with your example.
[1] https://github.com/lrytz/efftp/wiki/Relative-Effects
edit: That's effectively (sorry!) higher-order effects, behaving just as you'd expect.