on master help sign in
Simplify implementation of trim
fd5c458Johannes Griebler
src/Idris/REPLParser.hs+2−5
@@ -26,11 +26,8 @@ import qualified Data.ByteString.UTF8 as UTF8
26
26
27parseCmd :: IState -> String -> String -> Result (Either String Command)
27parseCmd :: IState -> String -> String -> Result (Either String Command)
28parseCmd i inputname = P.runparser pCmd i inputname . trim
28parseCmd i inputname = P.runparser pCmd i inputname . trim
29− where trim = fst . foldr f ("", True) . dropWhile isSpace
29+ where trim = f . f
30− where f e (xs, False) = (e : xs, False)
30+ where f = reverse . dropWhile isSpace
31− f e (xs, True)
32− | isSpace e = (xs, True)
33− | otherwise = (e : xs, False)
34
31
35type CommandTable = [ ( [String], CmdArg, String
32type CommandTable = [ ( [String], CmdArg, String
36 , String -> P.IdrisParser (Either String Command) ) ]
33 , String -> P.IdrisParser (Either String Command) ) ]