generateBindingFromGeneratorWith ::
       Binding -> NameGenerator -> (Binding, NameGenerator)
generateBindingFromGeneratorWith prefixBnd g = (h, g')
  where
    prefix = unwrap prefixBnd
    taken = g ^. takenNames
    prefix' = prefix <> "_"
    h = fromMaybe (error "IMPOSSIBLE") $
        safeHead $
        dropWhile (`HS.member` taken) $
        map (makeThrow . (prefix' <>) . show) ([0 ..] :: [Int])
    g' = g & takenNames %~ HS.insert h
generateBindingFromGeneratorWith ::
       Binding -> NameGenerator -> (Binding, NameGenerator)
generateBindingFromGeneratorWith prefixBnd g = (h, g')
  where
    prefix = unwrap prefixBnd
    taken = g ^. takenNames
    prefix' = prefix <> "_"
    h = fromMaybe (error "IMPOSSIBLE") $
        safeHead $
        dropWhile (`HS.member` taken) $
        map (makeThrow . (prefix' <>) . show) ([0 ..] :: [Int])
    g' = g & takenNames %~ HS.insert h
generateBindingFromGeneratorWith prefixBnd g = (h, g')
  where
    prefix = unwrap prefixBnd
    taken = g ^. takenNames
    prefix' = prefix <> "_"
    h = fromMaybe (error "IMPOSSIBLE") $
        safeHead $
        dropWhile (`HS.member` taken) $
        map (makeThrow . (prefix' <>) . show) ([0 ..] :: [Int])
    g' = g & takenNames %~ HS.insert h