literate scripts.
Malcolm Wallace
Malcolm.Wallace@cs.york.ac.uk
Tue, 5 Aug 2003 15:24:17 +0100
This is a multi-part message in MIME format.
--Multipart_Tue__5_Aug_2003_15:24:17_+0100_083512f8
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Immanuel Litzroth <immanuell@enfocus.be> writes:
> I have a small question relating to literate haskell programs that
> use the \begin{code} \end{code} style. Am I correct to assume that
> \end{code} inside a string should be recognized as being inside a
> string. The report seems to say this, but the unlit that is
> distributed with ghc doesn't grok this. Has anyone written an Unlit
> module in Haskell?
I have attached the Unlit.hs module from the nhc98 compiler, based
on the original specification in the the Haskell 1.2 Report. Use the
exported function
unlit :: String -> String -> String
whose first argument is the filename (for error messages), the second
argument is the file content, and whose result is the un-literated
file.
Regards,
Malcolm
--Multipart_Tue__5_Aug_2003_15:24:17_+0100_083512f8
Content-Type: text/plain;
name="Unlit.hs"
Content-Disposition: attachment;
filename="Unlit.hs"
Content-Transfer-Encoding: base64
bW9kdWxlIFVubGl0KHVubGl0KSB3aGVyZQoKLS0gUGFydCBvZiB0aGUgZm9sbG93aW5nIGNvZGUg
aXMgZnJvbQotLSAiUmVwb3J0IG9uIHRoZSBQcm9ncmFtbWluZyBMYW5ndWFnZSBIYXNrZWxsIiwK
LS0gICB2ZXJzaW9uIDEuMiwgYXBwZW5kaXggQy4KCmltcG9ydCBDaGFyCgpkYXRhIENsYXNzaWZp
ZWQgPSBQcm9ncmFtIFN0cmluZyB8IEJsYW5rIHwgQ29tbWVudAogICAgICAgICAgICAgICAgfCBJ
bmNsdWRlIEludCBTdHJpbmcgfCBQcmUgU3RyaW5nCgpjbGFzc2lmeSA6OiBbU3RyaW5nXSAtPiBb
Q2xhc3NpZmllZF0KY2xhc3NpZnkgW10gICAgICAgICAgICAgICAgPSBbXQpjbGFzc2lmeSAoKCdc
XCc6eCk6eHMpIHwgeCA9PSAiYmVnaW57Y29kZX0iID0gQmxhbmsgOiBhbGxQcm9nIHhzCiAgI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FuayAgICAgICA9ICIiCnVuY2xhc3NpZnkgQ29tbWVu
dCAgICAgPSAiIgoKdW5saXQgOjogU3RyaW5nIC0+IFN0cmluZyAtPiBTdHJpbmcKdW5saXQgZmls
ZSBsaHMgPSAodW5saW5lcwogICAgICAgICAgICAgICAgIC4gbWFwIHVuY2xhc3NpZnkKICAgICAg
ICAgICAgICAgICAuIGFkamVjZW50IGZpbGUgKDA6OkludCkgQmxhbmsKICAgICAgICAgICAgICAg
ICAuIGNsYXNzaWZ5KSAoaW5saW5lcyBsaHMpCgphZGplY2VudCA6OiBTdHJpbmcgLT4gSW50IC0+
IENsYXNzaWZpZWQgLT4gW0NsYXNzaWZpZWRdIC0+IFtDbGFzc2lmaWVkXQphZGplY2VudCBmaWxl
IDAgXyAgICAgICAgICAgICAoeCAgICAgICAgICAgICAgOnhzKSA9IHggOiBhZGplY2VudCBmaWxl
IDEgeCB4cyAtLSBmb3JjZSBldmFsdWF0aW9uIG9mIGxpbmUgbnVtYmVyCmFkamVjZW50IGZpbGUg
biB5QChQcm9ncmFtIF8pICh4QENvbW1lbnQgICAgICA6eHMpID0gZXJyb3IgKG1lc3NhZ2UgZmls
ZSBuICJwcm9ncmFtIiAiY29tbWVudCIpCmFkamVjZW50IGZpbGUgbiB5QChQcm9ncmFtIF8pICh4
QChJbmNsdWRlIGkgZik6eHMpID0geDogYWRqZWNlbnQgZiAgICBpICAgICB5IHhzCmFkamVjZW50
IGZpbGUgbiB5QChQcm9ncmFtIF8pICh4QChQcmUgXykgICAgICA6eHMpID0geDogYWRqZWNlbnQg
ZmlsZSAobisxKSB5IHhzCmFkamVjZW50IGZpbGUgbiB5QENvbW1lbnQgICAgICh4QChQcm9ncmFt
IF8pICA6eHMpID0gZXJyb3IgKG1lc3NhZ2UgZmlsZSBuICJjb21tZW50IiAicHJvZ3JhbSIpCmFk
amVjZW50IGZpbGUgbiB5QENvbW1lbnQgICAgICh4QChJbmNsdWRlIGkgZik6eHMpID0geDogYWRq
ZWNlbnQgZiAgICBpICAgICB5IHhzCmFkamVjZW50IGZpbGUgbiB5QENvbW1lbnQgICAgICh4QChQ
cmUgXykgICAgICA6eHMpID0geDogYWRqZWNlbnQgZmlsZSAobisxKSB5IHhzCmFkamVjZW50IGZp
bGUgbiB5QEJsYW5rICAgICAgICh4QChJbmNsdWRlIGkgZik6eHMpID0geDogYWRqZWNlbnQgZiAg
ICBpICAgICB5IHhzCmFkamVjZW50IGZpbGUgbiB5QEJsYW5rICAgICAgICh4QChQcmUgXykgICAg
ICA6eHMpID0geDogYWRqZWNlbnQgZmlsZSAobisxKSB5IHhzCmFkamVjZW50IGZpbGUgbiBfICAg
ICAgICAgICAgICh4QG5leHQgICAgICAgICA6eHMpID0geDogYWRqZWNlbnQgZmlsZSAobisxKSB4
IHhzCmFkamVjZW50IGZpbGUgbiBfICAgICAgICAgICAgIFtdICAgICAgICAgICAgICAgICAgICA9
IFtdCgptZXNzYWdlICJcIlwiIiBuIHAgYyA9ICJMaW5lICIrK3Nob3cgbisrIjogIisrcCsrICIg
bGluZSBiZWZvcmUgIisrYysrIiBsaW5lLlxuIgptZXNzYWdlIFtdICAgICBuIHAgYyA9ICJMaW5l
ICIrK3Nob3cgbisrIjogIisrcCsrICIgbGluZSBiZWZvcmUgIisrYysrIiBsaW5lLlxuIgptZXNz
YWdlIGZpbGUgICBuIHAgYyA9ICJJbiBmaWxlICIgKysgZmlsZSArKyAiIGF0IGxpbmUgIisrc2hv
dyBuKysiOiAiKytwKysgIiBsaW5lIGJlZm9yZSAiKytjKysiIGxpbmUuXG4iCgoKLS0gUmUtaW1w
bGVtZW50YXRpb24gb2YgJ2xpbmVzJywgZm9yIGJldHRlciBlZmZpY2llbmN5IChidXQgZGVjcmVh
c2VkIGxhemluZXNzKS4KLS0gQWxzbywgaW1wb3J0YW50bHksIGFjY2VwdHMgbm9uLXN0YW5kYXJk
IERPUyBhbmQgTWFjIGxpbmUgZW5kaW5nIGNoYXJhY3RlcnMuCmlubGluZXMgcyA9IGxpbmVzJyBz
IGlkCiAgd2hlcmUKICBsaW5lcycgW10gICAgICAgICAgICAgYWNjID0gW2FjYyBbXV0KICBsaW5l
cycgKCdcXk0nOidcbic6cykgYWNjID0gYWNjIFtdIDogbGluZXMnIHMgaWQJLS0gRE9TCiAgbGlu
ZXMnICgnXF5NJzpzKSAgICAgIGFjYyA9IGFjYyBbXSA6IGxpbmVzJyBzIGlkCS0tIE1hY09TCiAg
bGluZXMnICgnXG4nOnMpICAgICAgIGFjYyA9IGFjYyBbXSA6IGxpbmVzJyBzIGlkCS0tIFVuaXgK
ICBsaW5lcycgKGM6cykgICAgICAgICAgYWNjID0gbGluZXMnIHMgKGFjYyAuIChjOikpCgo=
--Multipart_Tue__5_Aug_2003_15:24:17_+0100_083512f8--