git.iko.soy/typeable/pandoc
on master help sign in
Removed (>>~) function

This function is equivalent to the more general (<*) which is defined in Control.Applicative. This change makes pandoc code easier to understand for those not familar with the codebase.

commit2fb8063f7869b43684796fb58d0ef08273fea0ba authorMatthew Pickering <matthewtpickering@gmail.com> dateFri 11 Jul 2014, 12:51 (12 years ago) parentf201bdc
6 files changed+17−22
src/Text/Pandoc/Parsing.hs+4−9 src/Text/Pandoc/Readers/HTML.hs+3−3 src/Text/Pandoc/Readers/LaTeX.hs+1−1 src/Text/Pandoc/Readers/Markdown.hs+4−4 src/Text/Pandoc/Readers/MediaWiki.hs+1−1 src/Text/Pandoc/Readers/RST.hs+4−4
src/Text/Pandoc/Parsing.hs+4−9
@@ -32,8 +32,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3232
3333A utility library with parsers used in pandoc readers.
3434-}
35−module Text.Pandoc.Parsing ( (>>~),
36− anyLine,
35+module Text.Pandoc.Parsing ( anyLine,
3736 many1Till,
3837 notFollowedBy',
3938 oneOfStrings,
@@ -101,6 +100,7 @@ module Text.Pandoc.Parsing ( (>>~),
101100 macro,
102101 applyMacros',
103102 Parser,
103+ ParserT,
104104 F(..),
105105 runF,
106106 askF,
@@ -205,11 +205,6 @@ instance Monoid a => Monoid (F a) where
205205 mappend = liftM2 mappend
206206 mconcat = liftM mconcat . sequence
207207
208−-- | Like >>, but returns the operation on the left.
209−-- (Suggested by Tillmann Rendel on Haskell-cafe list.)
210−(>>~) :: (Applicative m) => m a -> m b -> m a
211−a >>~ b = a <* b
212−
213208-- | Parse any line of text
214209anyLine :: Stream [Char] m Char => ParserT [Char] st m [Char]
215210anyLine = do
@@ -484,7 +479,7 @@ mathInlineWith op cl = try $ do
484479mathDisplayWith :: Stream s m Char => String -> String -> ParserT s st m String
485480mathDisplayWith op cl = try $ do
486481 string op
487− many1Till (noneOf "\n" <|> (newline >>~ notFollowedBy' blankline)) (try $ string cl)
482+ many1Till (noneOf "\n" <|> (newline <* notFollowedBy' blankline)) (try $ string cl)
488483
489484mathDisplay :: Stream s m Char => ParserT s ParserState m String
490485mathDisplay =
@@ -759,7 +754,7 @@ gridPart ch = do
759754 return (length dashes, length dashes + 1)
760755
761756gridDashedLines :: Stream s m Char => Char -> ParserT s st m [(Int,Int)]
762−gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) >>~ blankline
757+gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) <* blankline
763758
764759removeFinalBar :: String -> String
765760removeFinalBar =
src/Text/Pandoc/Readers/HTML.hs+3−3
@@ -128,7 +128,7 @@ pBulletList = try $ do
128128 -- note: if they have an <ol> or <ul> not in scope of a <li>,
129129 -- treat it as a list item, though it's not valid xhtml...
130130 skipMany nonItem
131− items <- manyTill (pInTags "li" block >>~ skipMany nonItem) (pCloses "ul")
131+ items <- manyTill (pInTags "li" block <* skipMany nonItem) (pCloses "ul")
132132 return $ B.bulletList $ map (fixPlains True) items
133133
134134pOrderedList :: TagParser Blocks
@@ -156,7 +156,7 @@ pOrderedList = try $ do
156156 -- note: if they have an <ol> or <ul> not in scope of a <li>,
157157 -- treat it as a list item, though it's not valid xhtml...
158158 skipMany nonItem
159− items <- manyTill (pInTags "li" block >>~ skipMany nonItem) (pCloses "ol")
159+ items <- manyTill (pInTags "li" block <* skipMany nonItem) (pCloses "ol")
160160 return $ B.orderedListWith (start, style, DefaultDelim) $ map (fixPlains True) items
161161
162162pDefinitionList :: TagParser Blocks
@@ -244,7 +244,7 @@ pTable :: TagParser Blocks
244244pTable = try $ do
245245 TagOpen _ _ <- pSatisfy (~== TagOpen "table" [])
246246 skipMany pBlank
247− caption <- option mempty $ pInTags "caption" inline >>~ skipMany pBlank
247+ caption <- option mempty $ pInTags "caption" inline <* skipMany pBlank
248248 -- TODO actually read these and take width information from them
249249 widths' <- pColgroup <|> many pCol
250250 head' <- option [] $ pOptInTag "thead" $ pInTags "tr" (pCell "th")
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -104,7 +104,7 @@ dimenarg = try $ do
104104
105105sp :: LP ()
106106sp = skipMany1 $ satisfy (\c -> c == ' ' || c == '\t')
107− <|> (try $ newline >>~ lookAhead anyChar >>~ notFollowedBy blankline)
107+ <|> (try $ newline <* lookAhead anyChar <* notFollowedBy blankline)
108108
109109isLowerHex :: Char -> Bool
110110isLowerHex x = x >= '0' && x <= '9' || x >= 'a' && x <= 'f'
src/Text/Pandoc/Readers/Markdown.hs+4−4
@@ -571,7 +571,7 @@ attributes :: MarkdownParser Attr
571571attributes = try $ do
572572 char '{'
573573 spnl
574− attrs <- many (attribute >>~ spnl)
574+ attrs <- many (attribute <* spnl)
575575 char '}'
576576 return $ foldl (\x f -> f x) nullAttr attrs
577577
@@ -688,7 +688,7 @@ birdTrackLine c = try $ do
688688--
689689
690690emailBlockQuoteStart :: MarkdownParser Char
691−emailBlockQuoteStart = try $ skipNonindentSpaces >> char '>' >>~ optional (char ' ')
691+emailBlockQuoteStart = try $ skipNonindentSpaces >> char '>' <* optional (char ' ')
692692
693693emailBlockQuote :: MarkdownParser [String]
694694emailBlockQuote = try $ do
@@ -1165,7 +1165,7 @@ gridPart ch = do
11651165 return (length dashes, length dashes + 1)
11661166
11671167gridDashedLines :: Char -> Parser [Char] st [(Int,Int)]
1168−gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) >>~ blankline
1168+gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) <* blankline
11691169
11701170removeFinalBar :: String -> String
11711171removeFinalBar =
@@ -1499,7 +1499,7 @@ inlinesBetween :: (Show b)
14991499inlinesBetween start end =
15001500 (trimInlinesF . mconcat) <$> try (start >> many1Till inner end)
15011501 where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)
1502− innerSpace = try $ whitespace >>~ notFollowedBy' end
1502+ innerSpace = try $ whitespace <* notFollowedBy' end
15031503
15041504strikeout :: MarkdownParser (F Inlines)
15051505strikeout = fmap B.strikeout <$>
src/Text/Pandoc/Readers/MediaWiki.hs+1−1
@@ -634,7 +634,7 @@ inlinesBetween :: (Show b) => MWParser a -> MWParser b -> MWParser Inlines
634634inlinesBetween start end =
635635 (trimInlines . mconcat) <$> try (start >> many1Till inner end)
636636 where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)
637− innerSpace = try $ whitespace >>~ notFollowedBy' end
637+ innerSpace = try $ whitespace <* notFollowedBy' end
638638
639639emph :: MWParser Inlines
640640emph = B.emph <$> nested (inlinesBetween start end)
src/Text/Pandoc/Readers/RST.hs+4−4
@@ -460,7 +460,7 @@ listItem :: RSTParser Int
460460listItem start = try $ do
461461 (markerLength, first) <- rawListItem start
462462 rest <- many (listContinuation markerLength)
463− blanks <- choice [ try (many blankline >>~ lookAhead start),
463+ blanks <- choice [ try (many blankline <* lookAhead start),
464464 many1 blankline ] -- whole list must end with blank.
465465 -- parsing with ListItemState forces markers at beginning of lines to
466466 -- count as list item markers, even if not separated by blank space.
@@ -480,7 +480,7 @@ listItem start = try $ do
480480
481481orderedList :: RSTParser Blocks
482482orderedList = try $ do
483− (start, style, delim) <- lookAhead (anyOrderedListMarker >>~ spaceChar)
483+ (start, style, delim) <- lookAhead (anyOrderedListMarker <* spaceChar)
484484 items <- many1 (listItem (orderedListStart style delim))
485485 let items' = compactify' items
486486 return $ B.orderedListWith (start, style, delim) items'
@@ -747,7 +747,7 @@ simpleReferenceName = do
747747
748748referenceName :: RSTParser Inlines
749749referenceName = quotedReferenceName <|>
750− (try $ simpleReferenceName >>~ lookAhead (char ':')) <|>
750+ (try $ simpleReferenceName <* lookAhead (char ':')) <|>
751751 unquotedReferenceName
752752
753753referenceKey :: RSTParser [Char]
@@ -1076,7 +1076,7 @@ explicitLink = try $ do
10761076
10771077referenceLink :: RSTParser Inlines
10781078referenceLink = try $ do
1079− (label',ref) <- withRaw (quotedReferenceName <|> simpleReferenceName) >>~
1079+ (label',ref) <- withRaw (quotedReferenceName <|> simpleReferenceName) <*
10801080 char '_'
10811081 state <- getState
10821082 let keyTable = stateKeys state