git.iko.soy/typeable/pandoc
on master help sign in
Remove F monad from Parsing
de093b4Matthew Pickering
src/Text/Pandoc/Parsing.hs+2−24
@@ -104,10 +104,6 @@ module Text.Pandoc.Parsing ( anyLine,
104 applyMacros',
104 applyMacros',
105 Parser,
105 Parser,
106 ParserT,
106 ParserT,
107− F(..),
108− runF,
109− askF,
110− asksF,
111 token,
107 token,
112 generalize,
108 generalize,
113 -- * Re-exports from Text.Pandoc.Parsec
109 -- * Re-exports from Text.Pandoc.Parsec
@@ -189,7 +185,7 @@ import Data.Default
189import qualified Data.Set as Set
185import qualified Data.Set as Set
190import Control.Monad.Reader
186import Control.Monad.Reader
191import Control.Monad.Identity
187import Control.Monad.Identity
192−import Control.Applicative ((<$>), (<*>), (*>), (<*), (<$), Applicative)
188+import Control.Applicative ((<$>), (<*>), (*>), (<*), (<$))
193import Data.Monoid
189import Data.Monoid
194import Data.Maybe (catMaybes)
190import Data.Maybe (catMaybes)
195
191
@@ -197,22 +193,6 @@ type Parser t s = Parsec t s
197
193
198type ParserT = ParsecT
194type ParserT = ParsecT
199
195
200−newtype F a = F { unF :: Reader ParserState a } deriving (Monad, Applicative, Functor)
201−
202−runF :: F a -> ParserState -> a
203−runF = runReader . unF
204−
205−askF :: F ParserState
206−askF = F ask
207−
208−asksF :: (ParserState -> a) -> F a
209−asksF f = F $ asks f
210−
211−instance Monoid a => Monoid (F a) where
212− mempty = return mempty
213− mappend = liftM2 mappend
214− mconcat = liftM mconcat . sequence
215−
216-- | Parse any line of text
196-- | Parse any line of text
217anyLine :: Stream [Char] m Char => ParserT [Char] st m [Char]
197anyLine :: Stream [Char] m Char => ParserT [Char] st m [Char]
218anyLine = do
198anyLine = do
@@ -914,7 +894,6 @@ data ParserState = ParserState
914 stateNotes :: NoteTable, -- ^ List of notes (raw bodies)
894 stateNotes :: NoteTable, -- ^ List of notes (raw bodies)
915 stateNotes' :: NoteTable', -- ^ List of notes (parsed bodies)
895 stateNotes' :: NoteTable', -- ^ List of notes (parsed bodies)
916 stateMeta :: Meta, -- ^ Document metadata
896 stateMeta :: Meta, -- ^ Document metadata
917− stateMeta' :: F Meta, -- ^ Document metadata
918 stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
897 stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
919 stateHeaders :: M.Map Inlines String, -- ^ List of headers and ids (used for implicit ref links)
898 stateHeaders :: M.Map Inlines String, -- ^ List of headers and ids (used for implicit ref links)
920 stateIdentifiers :: [String], -- ^ List of header identifiers used
899 stateIdentifiers :: [String], -- ^ List of header identifiers used
@@ -1011,7 +990,6 @@ defaultParserState =
1011 stateNotes = [],
990 stateNotes = [],
1012 stateNotes' = [],
991 stateNotes' = [],
1013 stateMeta = nullMeta,
992 stateMeta = nullMeta,
1014− stateMeta' = return nullMeta,
1015 stateHeaderTable = [],
993 stateHeaderTable = [],
1016 stateHeaders = M.empty,
994 stateHeaders = M.empty,
1017 stateIdentifiers = [],
995 stateIdentifiers = [],
@@ -1063,7 +1041,7 @@ data QuoteContext
1063
1041
1064type NoteTable = [(String, String)]
1042type NoteTable = [(String, String)]
1065
1043
1066−type NoteTable' = [(String, F Blocks)] -- used in markdown reader
1044+type NoteTable' = [(String, Blocks)] -- used in markdown reader
1067
1045
1068newtype Key = Key String deriving (Show, Read, Eq, Ord)
1046newtype Key = Key String deriving (Show, Read, Eq, Ord)
1069
1047
src/Text/Pandoc/Readers/Org.hs+1−2
@@ -39,8 +39,7 @@ import Text.Pandoc.Builder ( Inlines, Blocks, HasMeta(..), (<>)
39import Text.Pandoc.Definition
39import Text.Pandoc.Definition
40import Text.Pandoc.Options
40import Text.Pandoc.Options
41import qualified Text.Pandoc.Parsing as P
41import qualified Text.Pandoc.Parsing as P
42−import Text.Pandoc.Parsing hiding ( F, unF, askF, asksF, runF
43− , newline, orderedListMarker
42+import Text.Pandoc.Parsing hiding ( newline, orderedListMarker
44 , parseFromString, blanklines
43 , parseFromString, blanklines
45 )
44 )
46import Text.Pandoc.Readers.LaTeX (inlineCommand, rawLaTeXInline)
45import Text.Pandoc.Readers.LaTeX (inlineCommand, rawLaTeXInline)