On 06-Apr-2000, Chris Angus <[EMAIL PROTECTED]> wrote:
> I was wondering if there was any way to run code which possibly
> threw an error in any version of Haskell.
> 
> e.g.
> 
> efficient3rdPartyAlgorithm :: Int -> Int
> myOwnSlowAlgorithm :: Int -> Int
> 
> i.e. the idea is you run the efficent version and if 
> falls over you run your own version.

In ghc this is possible, using the "Exception" library.
See the ghc documentation for details.

However, that question is different to the topic of running
untrusted code, as you mention in your subject line.

AFAIK, none of the existing Haskell implementations have any
support for running untrusted code in a Java-like sandbox.
Instead, AFAIK all of them permit code to use operations
like `unsafePerformIO'.  Well, Hugs and ghc do have options
do disable extensions, like `unsafePerformIO'; if you run
code with extensions disabled, that will, I believe, 
serve as a fairly secure sandbox, although AFAIK no-one has
done any detailed security analysis of Haskell implementations
or the Haskell standard library.  But the drawback is that if you
use those options, then you also can't make use of safe extensions
like the "Exception" library (well, I think it's secure, but that's
just my first guess, I haven't really thought about it much).
There's no option which just disables unsecure extensions.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to