Yeah, sorry about that... I totally missed the ' in "f = formula s'" and "f = record s'"!
In that case, I would probably turn the whole thing into a case on "unitpropagate s", and get rid of the outer where, but my advice is clearly best taken with a pinch of salt.