git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: replace setState with updateState where possible
84db7e4Alexander Krotov
src/Text/Pandoc/Readers/Muse.hs+9−18
@@ -250,8 +250,7 @@ parseBlocks =
250 rest <- parseBlocks
250 rest <- parseBlocks
251 return $ first B.<> rest
251 return $ first B.<> rest
252 listStart = do
252 listStart = do
253− st <- getState
254− setState $ st{ museInPara = False }
253+ updateState (\st -> st { museInPara = False })
255 (first, rest) <- anyListUntil parseBlocks <|> amuseNoteBlockUntil parseBlocks
254 (first, rest) <- anyListUntil parseBlocks <|> amuseNoteBlockUntil parseBlocks
256 return $ first B.<> rest
255 return $ first B.<> rest
257 paraStart = do
256 paraStart = do
@@ -274,8 +273,7 @@ parseBlocksTill end =
274 rest <- continuation
273 rest <- continuation
275 return $ first B.<> rest
274 return $ first B.<> rest
276 listStart = do
275 listStart = do
277− st <- getState
278− setState $ st{ museInPara = False }
276+ updateState (\st -> st { museInPara = False })
279 (first, e) <- anyListUntil ((Left <$> end) <|> (Right <$> continuation))
277 (first, e) <- anyListUntil ((Left <$> end) <|> (Right <$> continuation))
280 case e of
278 case e of
281 Left _ -> return first
279 Left _ -> return first
@@ -309,8 +307,7 @@ listItemContentsUntil col pre end =
309 (rest, e) <- parsePre <|> continuation <|> parseEnd
307 (rest, e) <- parsePre <|> continuation <|> parseEnd
310 return (first B.<> rest, e)
308 return (first B.<> rest, e)
311 listStart = do
309 listStart = do
312− st <- getState
313− setState $ st{ museInPara = False }
310+ updateState (\st -> st { museInPara = False })
314 (first, e) <- anyListUntil ((Left <$> pre) <|> (Right <$> continuation) <|> (Left <$> end))
311 (first, e) <- anyListUntil ((Left <$> pre) <|> (Right <$> continuation) <|> (Left <$> end))
315 case e of
312 case e of
316 Left ee -> return (first, ee)
313 Left ee -> return (first, ee)
@@ -318,8 +315,7 @@ listItemContentsUntil col pre end =
318 continuation = try $ do blank <- optionMaybe blankline
315 continuation = try $ do blank <- optionMaybe blankline
319 skipMany blankline
316 skipMany blankline
320 indentWith col
317 indentWith col
321− st <- getState
322− setState $ st{ museInPara = museInPara st && isNothing blank }
318+ updateState (\st -> st { museInPara = museInPara st && isNothing blank })
323 listItemContentsUntil col pre end
319 listItemContentsUntil col pre end
324
320
325parseBlock :: PandocMonad m => MuseParser m (F Blocks)
321parseBlock :: PandocMonad m => MuseParser m (F Blocks)
@@ -331,8 +327,7 @@ parseBlock = do
331
327
332blockElements :: PandocMonad m => MuseParser m (F Blocks)
328blockElements :: PandocMonad m => MuseParser m (F Blocks)
333blockElements = do
329blockElements = do
334− st <- getState
335− setState $ st{ museInPara = False }
330+ updateState (\st -> st { museInPara = False })
336 choice [ mempty <$ blankline
331 choice [ mempty <$ blankline
337 , comment
332 , comment
338 , separator
333 , separator
@@ -480,8 +475,7 @@ amuseNoteBlockUntil end = try $ do
480 guardEnabled Ext_amuse
475 guardEnabled Ext_amuse
481 pos <- getPosition
476 pos <- getPosition
482 ref <- noteMarker <* spaceChar
477 ref <- noteMarker <* spaceChar
483− st <- getState
484− setState $ st{ museInPara = False }
478+ updateState (\st -> st { museInPara = False })
485 (content, e) <- listItemContentsUntil (sourceColumn pos) (fail "x") end
479 (content, e) <- listItemContentsUntil (sourceColumn pos) (fail "x") end
486 oldnotes <- museNotes <$> getState
480 oldnotes <- museNotes <$> getState
487 case M.lookup ref oldnotes of
481 case M.lookup ref oldnotes of
@@ -541,8 +535,7 @@ bulletListItemsUntil :: PandocMonad m
541bulletListItemsUntil indent end = try $ do
535bulletListItemsUntil indent end = try $ do
542 char '-'
536 char '-'
543 void spaceChar <|> lookAhead eol
537 void spaceChar <|> lookAhead eol
544− st <- getState
545− setState $ st{ museInPara = False }
538+ updateState (\st -> st { museInPara = False })
546 (x, e) <- listItemContentsUntil (indent + 2) (Right <$> try (optional blankline >> indentWith indent >> bulletListItemsUntil indent end)) (Left <$> end)
539 (x, e) <- listItemContentsUntil (indent + 2) (Right <$> try (optional blankline >> indentWith indent >> bulletListItemsUntil indent end)) (Left <$> end)
547 case e of
540 case e of
548 Left ee -> return ([x], ee)
541 Left ee -> return ([x], ee)
@@ -591,8 +584,7 @@ orderedListItemsUntil indent style end =
591 continuation = try $ do
584 continuation = try $ do
592 pos <- getPosition
585 pos <- getPosition
593 void spaceChar <|> lookAhead eol
586 void spaceChar <|> lookAhead eol
594− st <- getState
595− setState $ st{ museInPara = False }
587+ updateState (\st -> st { museInPara = False })
596 (x, e) <- listItemContentsUntil (sourceColumn pos) (Right <$> try (optionMaybe blankline >> indentWith indent >> museOrderedListMarker style >> continuation)) (Left <$> end)
588 (x, e) <- listItemContentsUntil (sourceColumn pos) (Right <$> try (optionMaybe blankline >> indentWith indent >> museOrderedListMarker style >> continuation)) (Left <$> end)
597 case e of
589 case e of
598 Left ee -> return ([x], ee)
590 Left ee -> return ([x], ee)
@@ -617,8 +609,7 @@ descriptionsUntil :: PandocMonad m
617 -> MuseParser m ([F Blocks], a)
609 -> MuseParser m ([F Blocks], a)
618descriptionsUntil indent end = do
610descriptionsUntil indent end = do
619 void spaceChar <|> lookAhead eol
611 void spaceChar <|> lookAhead eol
620− st <- getState
621− setState $ st{ museInPara = False }
612+ updateState (\st -> st { museInPara = False })
622 (x, e) <- listItemContentsUntil indent (Right <$> try (optional blankline >> indentWith indent >> manyTill spaceChar (string "::") >> descriptionsUntil indent end)) (Left <$> end)
613 (x, e) <- listItemContentsUntil indent (Right <$> try (optional blankline >> indentWith indent >> manyTill spaceChar (string "::") >> descriptionsUntil indent end)) (Left <$> end)
623 case e of
614 case e of
624 Right (xs, ee) -> return (x:xs, ee)
615 Right (xs, ee) -> return (x:xs, ee)