Created
February 6, 2014 21:48
-
-
Save AyeGill/8853178 to your computer and use it in GitHub Desktop.
Syntax example for haskell-based preprocessor idea.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ | |
--Arbitrary haskell code in double curly brackets | |
--Top-level definitions are available throughout text | |
emph s = "*" ++ s ++ "*" | |
}} | |
This will be rendered raw. | |
{{ | |
-- String-typed expressions will be printed into the final text wherever they appear | |
emph "This will be emphasized" | |
-- IO String-typed expressions will be evaluated, in the order that they appear in the file, and the values printed | |
emph `fmap` getContents | |
}} | |
Another thing that should be possible(paraphrasing a bit). | |
{{ | |
viewDiagram :: Diagram -> String -> IO String | |
-- Yes, Diagram is now a type, shut up. | |
viewDiagram d s = do | |
saveDiagram d s | |
return $ "\insertDiagram{"++s++"}" | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment