-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Text transformer and interpreter. -- -- Transf is simple text transformer and interpreter. -- -- It scans its input for guard tokens and passes everything between to -- transformation functions. Transformation functions are composed from a -- small set of combinators and may perform arbitrary Haskell -- computation. Transf contains a full Haskell interpreter and can even -- interpret its input as Haskell. -- -- The main purpose of Transf is to allow the embedding of -- Domain-Specific Languages in text or Markdown files. For example one -- could use it with Diagrams as follows: -- --
-- This is my file. Here is an image: -- -- ~~~diagram "A circle!" -- circle <> stretchX 2 square -- ~~~ ---- -- Transf can then generate the image, and replace the source in the text -- file with the name of the actual image. It can also include the -- source. -- --
-- This is my file. Here is an image: -- --  ---- -- You can supply your own file names. In the above example, the file -- name is a hash of the source code. @package transf @version 0.13 module Text.Transf -- | A single line of text. type Line = String -- | Multiple lines of text. type Lines = String type RelativePath = FilePath 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 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 => 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 Functor ArgDescr instance Functor OptDescr instance Eq (UserOpt a)