I've a library project which requires C's interoperability with other languages, and reasonable performance, but must be documented very clearly, à la literate programming, and whose documentation might benefit from a functional approach, like Haskell, or even Idris' proof features.
I'm therefore interested in building this library as a literate program, first writing the documentation and working Idris prototype code, and next writing C code that closely parallels the Idris code to address any performance issues and be easily linkable from other languages.
What literate programming tool do I want?
NuWeb is designed for multi-language literate programming, but their usage of the @ sign, or indeed any escape character, is problematic for functional languages like Idris, Haskell, etc.
Idris wants a literate programming tool to which I could contribute. I love their preferred approach of just using .tex
files delimited by \begin{code} .. \end{code}
blocks.
Idris, Haskell, etc. do not need tangle like C does, so doing that adds complexity and I'd prefer that any tool I'm using here sticks around.
An approach that minimizes tooling for library consumers might be to extract the C and Idris code using a simple Perl script like cat_latex_env
:
#!/usr/bin/perl
use strict;
use warnings;
sub usage { die "Usage: cat_latex_env enviroment_name [filename]\n"; }
usage if ($#ARGV < 0);
my $env = shift;
my $begin = quotemeta "\\begin{$env}";
my $end = quotemeta "\\end{$env}";
while (<>) {
if (/$begin/../$end/) {
next if /$begin/ || /$end/;
print;
}
}
At which point the Idris should compile fine. And I could embed the tangle instructions needed by a literate programming tool for C like CWEB or NuWeb.
Thoughts?