Text.Pandoc.Class.IO

pandoc-3.7.0.2: Conversion between markup formats

Copyright | Copyright (C) 2016-2020 Jesse Rosenthal John MacFarlane
License | GNU GPL, version 2 or above
Maintainer | Jesse Rosenthal <jrosenthal@jhu.edu>
Stability | alpha
Portability | portable
Safe Haskell | None
Language | Haskell2010

Text.Pandoc.Class.IO

Description

Default ways to perform ``PandocMonad`` actions in a ``MonadIO`` type.

These functions are used to make the ``PandocIO`` type an instance of ``PandocMonad``, but can be reused for any other MonadIO-conforming types.

Synopsis

- fileExists :: (PandocMonad m, MonadIO m) => FilePath -> m Bool
- getCurrentTime :: MonadIO m => m UTCTime
- getCurrentTimeZone :: MonadIO m => m TimeZone
- getDataFileName :: (PandocMonad m, MonadIO m) => FilePath -> m FilePath
- getModificationTime :: (PandocMonad m, MonadIO m) => FilePath -> m UTCTime
- glob :: (PandocMonad m, MonadIO m) => String -> m [FilePath]
- logOutput :: (PandocMonad m, MonadIO m) => LogMessage -> m ()
- logIOError :: (PandocMonad m, MonadIO m) => IO () -> m ()
- lookupEnv :: MonadIO m => Text -> m (Maybe Text)
- newStdGen :: MonadIO m => m StdGen
- newUniqueHash :: MonadIO m => m Int
- openURL :: (PandocMonad m, MonadIO m) => Text -> m (ByteString, Maybe MimeType)
- readFileLazy :: (PandocMonad m, MonadIO m) => FilePath -> m ByteString
- readFileStrict :: (PandocMonad m, MonadIO m) => FilePath -> m ByteString
- readStdinStrict :: (PandocMonad m, MonadIO m) => m ByteString
- extractMedia :: (PandocMonad m, MonadIO m) => FilePath -> Pandoc -> m Pandoc
- writeMedia :: (PandocMonad m, MonadIO m) => FilePath -> (FilePath, MimeType, ByteString) -> m ()

# Documentation

fileExists :: (PandocMonad m, MonadIO m) => FilePath -> m Bool #

Returns True if file exists.

getCurrentTime :: MonadIO m => m UTCTime #

Get the current (UTC) time.

getCurrentTimeZone :: MonadIO m => m TimeZone #

Get the locale's time zone.

getDataFileName :: (PandocMonad m, MonadIO m) => FilePath -> m FilePath #

Returns the path of data file.

getModificationTime :: (PandocMonad m, MonadIO m) => FilePath -> m UTCTime #

Return the modification time of a file.

glob :: (PandocMonad m, MonadIO m) => String -> m [FilePath] #

Return a list of paths that match a glob, relative to the working directory. See `Glob` for the glob syntax.

logOutput :: (PandocMonad m, MonadIO m) => LogMessage -> m () #

Output a log message.

logIOError :: (PandocMonad m, MonadIO m) => IO () -> m () #

Show potential IO errors to the user continuing execution anyway

lookupEnv :: MonadIO m => Text -> m (Maybe Text) #

Lookup an environment variable in the programs environment.

newStdGen :: MonadIO m => m StdGen #

Return a new generator for random numbers.

newUniqueHash :: MonadIO m => m Int #

Return a new unique integer.

openURL :: (PandocMonad m, MonadIO m) => Text -> m (ByteString, Maybe MimeType) #

readFileLazy :: (PandocMonad m, MonadIO m) => FilePath -> m ByteString #

Read the lazy ByteString contents from a file path, raising an error on failure.

readFileStrict :: (PandocMonad m, MonadIO m) => FilePath -> m ByteString #

Read the strict ByteString contents from a file path, raising an error on failure.

readStdinStrict :: (PandocMonad m, MonadIO m) => m ByteString #

Read the strict ByteString contents from stdin, raising an error on failure.

extractMedia :: (PandocMonad m, MonadIO m) => FilePath -> Pandoc -> m Pandoc #

Extract media from the mediabag into a directory.

writeMedia :: (PandocMonad m, MonadIO m) => FilePath -> (FilePath, MimeType, ByteString) -> m () #

Write the contents of a media bag to a path. If the path contains URI escape sequences (percent-encoding), these are resolved.