update :: Int -> a -> Queue a -> Queue a
update i x (Q lenf f state lenr r) = if i < lenf
  then let f' = L.update i x f in Q lenf f' state lenr r
  else let r' = L.update (lenr - (i - lenf) - 1) x r in Q lenf f state lenr r'
update :: Int -> a -> Queue a -> Queue a
update i x (Q lenf f state lenr r) = if i < lenf
  then let f' = L.update i x f in Q lenf f' state lenr r
  else let r' = L.update (lenr - (i - lenf) - 1) x r in Q lenf f state lenr r'
update i x (Q lenf f state lenr r) = if i < lenf
  then let f' = L.update i x f in Q lenf f' state lenr r
  else let r' = L.update (lenr - (i - lenf) - 1) x r in Q lenf f state lenr r'