From 44c11647f808f1eb3b29790964cc0f9d47ce6902 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Dec 2015 16:34:52 -0500 Subject: [PATCH] Use the Alternative instance for skipping spaces too. --- src/Range.hs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Range.hs b/src/Range.hs index 825f09ca1..caff64a08 100644 --- a/src/Range.hs +++ b/src/Range.hs @@ -18,12 +18,9 @@ offsetRange i (Range start end) = Range (i + start) (i + end) rangesAndWordsFrom :: Int -> String -> [(Range, String)] rangesAndWordsFrom _ "" = [] rangesAndWordsFrom startIndex string = - case takeAndContinue <$> (word <|> punctuation) of + case takeAndContinue <$> (word <|> punctuation) <|> skipAndContinue <$> space of Just a -> a - Nothing -> - case space of - Just parsed -> skipAndContinue parsed - Nothing -> [] + Nothing -> [] where word = parse isWord string punctuation = parse (not . isWordOrSpace) string