https://github.com/jameysharp/corrode/blob/master/src/Langua...
https://github.com/jameysharp/corrode/blob/master/src/Langua...
Kinda taking Rust's doc unit tests format to a whole new level.
-- foo is a function
foo :: String -> String
It's foo is a function
> foo :: String -> StringEdit: I should have looked more closely, sorry.
My tool of choice for this is Emacs org-mode with noweb support. The source file is "tangled" (i.e. individual chunks of code are glued back together in a specified order) to create the source for the compiler to process.
Haskell itself has only limited support for literate programming. Most importantly it lacks the ability to reorder chunks of code. (noweb or org-mode babel can be used with Haskell, of course.)
The literate programming tangle process mainly exists to remove Pascal's order restrictions.
It can be nice to have a single document explaining the whole project, producing individual source files upon tangling. For this approach you need control over order and target files. "Literate Haskell" is hardly more than a reversal of the meaning of comments and code.
haskell.org [1] says there is "bird style" and "LaTeX style" ways of marking off code vs documentation, and I see neither in the linked file. Is it the "```haskell" blocks?
[1] https://wiki.haskell.org/Literate_programming#Haskell_and_li...
To so this yourself you need to add the --markdown-unlit flag to ghc and add the package "markdown-unlit" to your dependencies. Additionally you have to symlink your .md file to .lhs, as ghc does not look at .md files (even with the --markdown-unlit flag, which I find kinda sad)