Patrick Marchand is a user on bsd.network. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
Patrick Marchand @mathuin

My new class asks that we send our code in as a pdf, so I'm experimenting with , and it's pretty fun to learn at the same time.

I started with some literate but decided to switch to a more language agnostic solution as we will also be using , and .

So right now I'm directly writing documents in , with haskell interspersed through the documents, I'm counting on extracting the haskell code with awk or sam and piping it to ghc.

· Web · 0 · 4

I have spent some time researching literate programming solutions and while there is a lot of language specific solutions, there arent many language-agnostic ones.

cs.tufts.edu/~nr/noweb/
does not seem actively developed and does not have a package on my naive attempt at compiling it did not go well.

github.com/zyedidia/Literate
is interesting, but as far as I know, there's no way to run programs on openbsd yet.

@mathuin why not some tool that was specifically written for literate programming, like noweb?

@grainloom Too lazy to port it to openbsd

And a little yak-shaving never hurt a man

@grainloom I shared an example of what I did to the rest of my class here:
github.com/Superpat/ulit

It's reeeeeal simple.

@mathuin Put the haskell code inside latex comments, prepend the code with > and tell ghc that it's aliteral haskell file :)

@ckeen Yeah i know that would work, but sort of wanted to try a solution that would work with many different languages.

@ckeen You mean leave Acme? Haha but yeah org-mode could be an idea.

@mathuin I have tried several literate programming tooling over the years and most are meh...

The original one forces you to chunk out your code funnily and in the end forces you to latex, so now you have two problems all of a sudden.

Something lightweight like literal haskell files have been the most practical.

I think if you don't need chunking you can get away with an arbitrary code marker and an awk script to weave your literate file into a source file.

@ckeen Latex is already a requirement of the course I'm taking, so thats moot.

And yes, I've been getting away with an awk script for now.

@mathuin @ckeen I heard there was a troff pre processor that was used by W. R. Stevens and others to produce excellent books

@saper @mathuin most people wrote their own. Do you happen to know its name?

@mathuin One could call emacs in batch mode from ACME too :)

@mathuin You don't need an extra pipe but can run ghc and LaTeX on the same files: use \begin{code} and \end{code}, name the files .lhs and then \include or \input them in main.tex.

Here is a bigger example I made for a course last year: github.com/funcspec/report-exa