@@ -39,7 +39,7 @@ module Text.Pandoc.Readers.Org.ParserState
3939 , TodoState (..)
4040 , activeTodoMarkers
4141 , registerTodoSequence
42− , F(..)
42+ , F
4343 , askF
4444 , asksF
4545 , trimInlinesF
@@ -50,14 +50,13 @@ module Text.Pandoc.Readers.Org.ParserState
5050 , optionsToParserState
5151 ) where
5252
53−import Control.Monad (liftM, liftM2)
54−import Control.Monad.Reader (Reader, ReaderT, ask, asks, local, runReader)
53+import Control.Monad.Reader (ReaderT, asks, local)
5554
5655import Data.Default (Default (..))
5756import qualified Data.Map as M
5857import qualified Data.Set as Set
5958
60−import Text.Pandoc.Builder (Blocks, Inlines, trimInlines)
59+import Text.Pandoc.Builder (Blocks, Inlines)
6160import Text.Pandoc.Definition (Meta (..), nullMeta)
6261import Text.Pandoc.Options (ReaderOptions (..))
6362import Text.Pandoc.Logging
@@ -65,7 +64,12 @@ import Text.Pandoc.Parsing (HasHeaderMap (..), HasIdentifierList (..),
6564 HasLogMessages (..),
6665 HasLastStrPosition (..), HasQuoteContext (..),
6766 HasReaderOptions (..), ParserContext (..),
68− QuoteContext (..), SourcePos)
67+ QuoteContext (..), SourcePos, Future,
68+ askF, asksF, returnF, runF, trimInlinesF)
69+
70+-- | This is used to delay evaluation until all relevant information has been
71+-- parsed and made available in the parser state.
72+type F = Future OrgParserState
6973
7074-- | An inline note / footnote containing the note key and its (inline) value.
7175type OrgNoteRecord = (String, F Blocks)
@@ -229,35 +233,3 @@ defaultExportSettings = ExportSettings
229233 , exportWithEmail = True
230234 , exportWithTodoKeywords = True
231235 }
232−
233−
234−--
235−-- Parser state reader
236−--
237−
238−-- | Reader monad wrapping the parser state. This is used to delay evaluation
239−-- until all relevant information has been parsed and made available in the
240−-- parser state. See also the newtype of the same name in
241−-- Text.Pandoc.Parsing.
242−newtype F a = F { unF :: Reader OrgParserState a
243− } deriving (Functor, Applicative, Monad)
244−
245−instance Monoid a => Monoid (F a) where
246− mempty = return mempty
247− mappend = liftM2 mappend
248− mconcat = fmap mconcat . sequence
249−
250−runF :: F a -> OrgParserState -> a
251−runF = runReader . unF
252−
253−askF :: F OrgParserState
254−askF = F ask
255−
256−asksF :: (OrgParserState -> a) -> F a
257−asksF f = F $ asks f
258−
259−trimInlinesF :: F Inlines -> F Inlines
260−trimInlinesF = liftM trimInlines
261−
262−returnF :: Monad m => a -> m (F a)
263−returnF = return . return