Opened 9 years ago

Last modified 4 years ago

#2427 new feature request

Allow compilation of source from stdin

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.8.3
Keywords: Cc: gwern0@…, id@…, nathanhowell@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by igloo)

Hiya. So, as part of how the Hint library (a wrapper around the GHC API operates), it has to generate a file in /tmp containing module boilerplate and the supplied code of interesting, and it then evaluates it*. But for my mueval code (which uses Hint), I'd like to disable file creation entirely through resource limits, and so it would be much better for Hint if it could instead just create the string and pipe it right into GHC. This avoids any file creation (which may not be possible for any number of reasons besides resource limits, like LiveCDs or read-only disks). But in my experiments, and those of #haskell, GHC determinedly blocks any attempt - you can't simply pipe it in with |, you can't use /dev/stdin, can't use one of the file descriptors, etc.

So what I would like is to be able to do:

$ echo "import qualified Data.List\nmain = print $ Data.List.intersperse 'f' "ggggg"


(Why can't I use ghc -e? Doesn't do imports of any kind, and if mueval is to replicate lambdabot's functionality, it needs to be able to import many libraries qualified.)

  • It has to do this roundabout hackish thing because alas, the GHC API seems to allow functions from any module whatsoever to be called as long as they are named qualified, even if the appropriate module had not been allowed in. The magnitude of this as a security hole is obvious.

Why qualified? Too many of the basic libraries have name collisions. Can't remove them, as it'd be silly to have only half the base libraries or whatever, but can't just blindly import them as you'll get conflicts.

Change History (9)

comment:1 Changed 9 years ago by Isaac Dupree

Cc: id@… added

I ran into this before too. I think it was when I was trying to run QuickCheck stuff with some script... Anyway, that could work fine for a single module, but GHC doesn't allow multiple modules in the same file, if you want to allow executing anything fancy like that using only stdin ( reminding me to put #2428 ).

comment:2 Changed 9 years ago by guest

Actually, I just remembered - this could be useful in Darcs as well. Currently Darcs's configure script generates a bunch of files with different module & FFI imports (corresponding to various functionalities to enable/disable) and sees whether they compile; if GHC returned a non-zero exit code on failed compilation of stdin, then that would simplify things a little bit.

comment:3 Changed 9 years ago by igloo

Description: modified (diff)
difficulty: Unknown

comment:4 Changed 8 years ago by igloo

Milestone: 6.12 branch
Priority: normallow

This is probably quite low priority for us currently, so do add yourself to this ticket if it's important for you.

comment:5 Changed 8 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:6 Changed 8 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:7 Changed 7 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:8 Changed 7 years ago by igloo

Milestone: 6.12.3_|_
Priority: lownormal
Type of failure: None/Unknown

comment:9 Changed 4 years ago by nathanhowell

Cc: nathanhowell@… added
Note: See TracTickets for help on using tickets.