Skip to content

Instantly share code, notes, and snippets.

@AyeGill
Created February 6, 2014 21:48
Show Gist options
  • Save AyeGill/8853178 to your computer and use it in GitHub Desktop.
Save AyeGill/8853178 to your computer and use it in GitHub Desktop.
Syntax example for haskell-based preprocessor idea.
{{
--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