Constant files/Re: Here-docs in Haskell source

Jon Fairbairn jon.fairbairn at
Mon Sep 25 12:37:39 EDT 2006

On 2006-09-24 at 01:59BST "Neil Mitchell" wrote:
> As a side note, perhaps if you're shoving massive amounts of text into
> a Haskell source file you want to either move to something more
> structured (like haskell source extensions),

IIRC the original problem was MySQL statements, which really
call out for something structured. Having them as strings
throws away potential compile-time checks.

> or if it really is just some large constant, then put it
> in a separate file.

That reminds me of an idea I've had rumbling about in my
head for some time: files as constants. It goes something
like this:

A module may import a directory (folder?) using some special
syntax (or hypothetical module name), and all the files in
the directory become names available to the module. In the
simplest version, the files would just correspond to names
of type String, but more structure would be possible (and
probably desirable).

So, let's suppose that the directory D contains files foo
and bar, a module could say something like

   import ConstantFiles/D (foo)

   main = putStr foo

and the compiler would instruct the linker that D/foo was to
be included in the resulting programme (possibly at load
time?) bound to the name foo.

There are plenty of details to be worked out (including what
mapping for filenames to variable names, encodings - which
the compiler would have to check, searchpath resolution,
...), which is why I've not got round to posting this
before, but I think the idea has potential.

Jón Fairbairn                              Jon.Fairbairn at

More information about the Haskell-prime mailing list