1
Fork 0
simple-sql-parser/tests/FilterSpaces.hs
Jake Wheat 45669ed7d3 reorganise
move exe example to examples/
get rid of the second example
move tests to tests/
don't shadow show in Pretty
2024-01-26 15:28:15 +00:00

25 lines
575 B
Haskell

--import System.IO
import System.Environment
main :: IO ()
main = do
[a] <- getArgs
r <- readFile a
let ls = lines r
putStrLn $ unlines $ map dedupeSpaces ls
dedupeSpaces :: String -> String
dedupeSpaces [] = []
-- don't start until after the leading spaces
-- including literate haskell source lines
dedupeSpaces xs@(x:_) | x `notElem` " >" = dedupeSpaces' xs
dedupeSpaces (x:xs) = x : dedupeSpaces xs
dedupeSpaces' :: String -> String
dedupeSpaces' (' ':xs@(' ':_)) = dedupeSpaces' xs
dedupeSpaces' (x:xs) = x : dedupeSpaces' xs
dedupeSpaces' [] = []