-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Text transformer and interpreter. -- @package transf @version 0.13.1 module Text.Transf -- | A single line of text. type Line = String -- | Multiple lines of text. type Lines = String -- | A relative file path. type RelativePath = FilePath -- | The Context monad defines the context of a transformation. -- -- The main purpose of this type is to restrict the the number of -- functions you can pass to transform. type Context = ContextT IO data ContextT m a -- | Run a computation in the Context monad. runContext :: Context a -> IO (Either String a) runContextT :: Monad m => ContextT m a -> m (Either String a) -- | A transformation. data Transform -- | Create a new transformation. -- -- This transformation processes everything in between lines containing a -- fence such as -- --
--   ~~~name
--   ~~~
--   
-- -- or -- --
--   ```name
--   ```
--   
-- -- where name is the name of the transformation. -- -- To create a suitable change function, use the combinators defined -- below. transform :: String -> (Lines -> Context Lines) -> Transform -- | Run a transformation in the Context monad. runTransform :: Transform -> String -> Context String -- | Read a file. readFile :: RelativePath -> Context String -- | Write to a file. writeFile :: RelativePath -> String -> Context () -- | Write to the standard error stream. inform :: String -> Context () -- | Evaluate a Haskell expression. eval :: Typeable a => String -> Context a -- | Evaluate a Haskell expression with the given modules in scope. Note -- that Prelude is not implicitly imported. -- -- All requested modules must be present on the system or the computation -- will fail. Also, the string must be a valid Haskell expression using -- constructs which in scope after loading the given modules. -- -- Errors can be caught using catchError. evalWith :: Typeable a => [String] -> String -> Context a -- | Register an action to be run after text processing has finished. This -- can be used to optimize tasks such as external file generations. -- -- Note that addPost does not work trasitively, i.e. post actions of post -- actions are thrown away. addPost :: Context () -> Context () -- | This named transformation posts its input to the standard error stream -- and returns nothing. printT :: Transform -- | This named transformation evaluates its input as a Haskell expression -- of type String and returns the value of the expression. -- -- For example the input -- --
--   ~~~haskell
--   "The number is " ++ show $ 3 + 2
--   ~~~
--   
-- -- Will be transformed into -- --
--   The number is 6
--   
evalT :: Transform -- | This named transformation evaluates its input as a music expression. -- -- The music is rendered as an .ly file and a .mid -- fiel, then lilypond and convert is run to render a -- .png file. A markdown image tag and a HTML play and stop -- button is returned. -- -- The expression must return a value of type Score Note. The -- Music.Prelude.Basic module is implicitly imported. musicT :: Transform data MusicOpts MusicOpts :: String -> Int -> Int -> String -> MusicOpts format :: MusicOpts -> String resolution :: MusicOpts -> Int resize :: MusicOpts -> Int prelude :: MusicOpts -> String musicT' :: MusicOpts -> Transform -- | This named transformation passes everything through and retains the -- source. haskellT :: Transform evalHaskellT :: Transform -- | This named transformation runs the music transformation and -- retains the source. musicHaskellT :: Transform musicHaskellT' :: MusicOpts -> Transform -- | This named transformation includes stuff needed for music playback. -- -- It should be used exactly once in the document. musicExtraT :: Transform instance Functor m => Functor (ContextT m) instance Monad m => Monad (ContextT m) instance MonadIO m => MonadIO (ContextT m) instance Monad m => MonadPlus (ContextT m) instance (Monad m, Functor m) => Applicative (ContextT m) instance (Monad m, Functor m) => Alternative (ContextT m) instance Monad m => MonadError String (ContextT m) instance Monad m => MonadWriter (Post m) (ContextT m) instance Monoid (Post m) instance Default MusicOpts instance Monoid Transform instance Semigroup Transform module Text.Transf.Process -- | Creates a Unix style text processor from a Transform. -- -- The resulting action should be used as the main of an application and -- will render a program of the given name that responds to -v -- and -h flags. If given no flags it runs the text transformer -- over the standard input and output streams. If an error occurs the -- program halts and prints an error message to the standard error -- stream. -- --
--   defaultMain name transf
--   
defaultMain :: String -> Transform -> IO () -- | Like defaultMain, but customizes the transform based on the -- given options. -- -- The help and version flags are added automatically. -- --
--   defaultMain' name opts transf
--   
defaultMain' :: String -> [OptDescr a] -> ([a] -> Transform) -> IO () instance Eq (UserOpt a)