implementing [state, f]  for handlers