Literate Haskell - capturing output

Hello all, I am using literate haskell quite a lot (otherwise I don't understand my own code). This works fine for the code as such. But when I give an example usage, I run code snippets in ghci and copy&paste into the main document/program, which turns them into "text" (and not code). When I make changes to the program these examples tend to no longer reflect the actual program. Is there a way to automatically run examples and include them in the .lhs file, preferably with the haskell prompt and everything? -- Martin

On Thu, Jan 17, 2013 at 08:00:43PM +0100, Martin Drautzburg wrote:
Hello all,
I am using literate haskell quite a lot (otherwise I don't understand my own code). This works fine for the code as such. But when I give an example usage, I run code snippets in ghci and copy&paste into the main document/program, which turns them into "text" (and not code).
When I make changes to the program these examples tend to no longer reflect the actual program.
Is there a way to automatically run examples and include them in the .lhs file, preferably with the haskell prompt and everything?
This sounds nice but I don't know of any such thing. It shouldn't be too bad to parse a literate Haskell file with haskell-src-exts, process some of the literate comments, and then write it back out. Unfortunately I do not know of a nice way to capture ghci output. You can find an extremely hacky solution in BlogLiterately, much of which was copied from the lhs2TeX source: http://hub.darcs.net/byorgey/BlogLiterately/browse/src/Text/BlogLiterately/G... -Brent

On Fri, Jan 18, 2013 at 12:30 AM, Martin Drautzburg < Martin.Drautzburg@web.de> wrote:
Hello all,
I am using literate haskell quite a lot (otherwise I don't understand my own code). This works fine for the code as such. But when I give an example usage, I run code snippets in ghci and copy&paste into the main document/program, which turns them into "text" (and not code).
When I make changes to the program these examples tend to no longer reflect the actual program.
Is there a way to automatically run examples and include them in the .lhs file, preferably with the haskell prompt and everything?
If you are ok with emacs, emacs -> orgmode -> babel may be worth a consider http://orgmode.org/worg/org-contrib/babel/intro.html http://www.jstatsoft.org/v46/i03/paper -- http://www.the-magus.in http://blog.languager.org

On Thu, Jan 31, 2013 at 7:55 PM, Rustom Mody
On Fri, Jan 18, 2013 at 12:30 AM, Martin Drautzburg < Martin.Drautzburg@web.de> wrote:
Hello all,
I am using literate haskell quite a lot (otherwise I don't understand my own code). This works fine for the code as such. But when I give an example usage, I run code snippets in ghci and copy&paste into the main document/program, which turns them into "text" (and not code).
When I make changes to the program these examples tend to no longer reflect the actual program.
Is there a way to automatically run examples and include them in the .lhs file, preferably with the haskell prompt and everything?
If you are ok with emacs, emacs -> orgmode -> babel may be worth a consider http://orgmode.org/worg/org-contrib/babel/intro.html http://www.jstatsoft.org/v46/i03/paper
http://www.cs.unm.edu/~eschulte/data/CISE-13-3-SciProg.pdf maybe a better read

On Thursday, 31. January 2013 15:25:56 Rustom Mody wrote:
If you are ok with emacs, emacs -> orgmode -> babel may be worth a consider http://orgmode.org/worg/org-contrib/babel/intro.html http://www.jstatsoft.org/v46/i03/paper
Yes, I'm okay with emacs and I use org-mode a lot. Can you point be to an example of using org-mode with haskell? I've only seen that as a way to add program output to a documentation, but will I still end up with a runnable haskell program? -- Martin

On Sat, Feb 2, 2013 at 2:53 AM, Martin Drautzburg
On Thursday, 31. January 2013 15:25:56 Rustom Mody wrote:
If you are ok with emacs, emacs -> orgmode -> babel may be worth a consider http://orgmode.org/worg/org-contrib/babel/intro.html http://www.jstatsoft.org/v46/i03/paper
Yes, I'm okay with emacs and I use org-mode a lot. Can you point be to an example of using org-mode with haskell? I've only seen that as a way to add program output to a documentation, but will I still end up with a runnable haskell program? -- Martin
No I dont have a ready example. Im sure if you ask on the org mode mailing list, (perhaps after supplying a toy example) you will get a babel-ed version.
participants (4)
-
Brent Yorgey
-
Kim-Ee Yeoh
-
Martin Drautzburg
-
Rustom Mody