haskell / alex

A lexical analyser generator for Haskell
https://hackage.haskell.org/package/alex
BSD 3-Clause "New" or "Revised" License
297 stars 82 forks source link

Functions `Sort.isort` and `Sort.insrt` not used #230

Closed ivanperez-keera closed 1 year ago

ivanperez-keera commented 1 year ago

The function Sort.isort is not used by any part of alex. A quick search through the tree can show this:

$ grep -nHre 'isort' 
src/Sort.hs:5:complete with associated functions for inserting and merging.  `isort' is the
src/Sort.hs:25:-- `isort' is an insertion sort and is here for historical reasons; msort is
src/Sort.hs:28:isort:: (a->a->Bool) -> [a] -> [a]
src/Sort.hs:29:isort (<=) = foldr (insrt (<=)) []

The function Sort.insrt is only used by Sort.isort:

$ grep -nHre 'insrt' 
src/Sort.hs:29:isort (<=) = foldr (insrt (<=)) []
src/Sort.hs:31:insrt:: (a->a->Bool) -> a -> [a] -> [a]
src/Sort.hs:32:insrt _    e [] = [e]
src/Sort.hs:33:insrt (<=) e l@(h:t) = if e<=h then e:l else h:insrt (<=) e t

Since alex doesn't expose an API and neither function is ultimately used, they can both be removed.

ivanperez-keera commented 1 year ago

If you are ok with it, I'd like to send a PR. It's ready.

andreasabel commented 1 year ago

If you are ok with it, I'd like to send a PR. It's ready.

Sure. This is just historic code, if you want to delete it, I am fine with it.