step :: Rules -> Polymer -> Polymer
step !rules !polymer = (p :) . concatMap lookupAndSplice $ zip polymer ps
 where
    !p = head polymer
    !ps = tail polymer
    lookupAndSplice (!a, !b) = case rules M.!? (a, b) of
      Nothing -> []
      Just !x -> [x, b]
step :: Rules -> Polymer -> Polymer
step !rules !polymer = (p :) . concatMap lookupAndSplice $ zip polymer ps
 where
    !p = head polymer
    !ps = tail polymer
    lookupAndSplice (!a, !b) = case rules M.!? (a, b) of
      Nothing -> []
      Just !x -> [x, b]
step !rules !polymer = (p :) . concatMap lookupAndSplice $ zip polymer ps
 where
    !p = head polymer
    !ps = tail polymer
    lookupAndSplice (!a, !b) = case rules M.!? (a, b) of
      Nothing -> []
      Just !x -> [x, b]