From ca7e1f5ff1baf9c5f45c422b64c17185e18d2253 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Dec 2015 15:02:09 -0500 Subject: [PATCH] Document the word character predicate. --- src/Range.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Range.hs b/src/Range.hs index 0bc43f62b..4c9e14054 100644 --- a/src/Range.hs +++ b/src/Range.hs @@ -22,6 +22,9 @@ rangesOfWordsFrom startIndex string = case break Char.isSpace string of (word, rest) -> (Range startIndex $ startIndex + length word) : rangesOfWordsAfterWhitespace (startIndex + length word) rest where rangesOfWordsAfterWhitespace startIndex string | (whitespace, rest) <- break (not . Char.isSpace) string = rangesOfWordsFrom (startIndex + length whitespace) rest + -- | Is this a word character? + -- | Word characters are defined as in [Ruby’s `\p{Word}` syntax](http://ruby-doc.org/core-2.1.1/Regexp.html#class-Regexp-label-Character+Properties), i.e.: + -- | > A member of one of the following Unicode general category _Letter_, _Mark_, _Number_, _Connector_Punctuation_ isWord c = Char.isLetter c || Char.isNumber c || Char.isMark c || Char.generalCategory c == Char.ConnectorPunctuation