10

I'm writing some disposable Haskell scripts to solve some of the Project Euler problems. I don't really want to have to compile them because of the number of changes I'm constantly having to make, but in a few cases I've found that I've run out of stack space.

The documentation for runhaskell says that the following syntax should increase the stack space:

runhaskell +RTS -K5M -RTS Script.hs

This never, ever works (in any permutation I've tried). The stack size always remains 8,388,608. This is maddening, and I haven't found much help on Google.

Any suggestions? What am I doing wrong?

ale
  • 6,369
  • 7
  • 55
  • 65
Gregory Higley
  • 15,923
  • 9
  • 67
  • 96

3 Answers3

8

I'm guessing you're using GHC. Chapter 4 of the User's Guide of the newly released 6.10.1 says:

The only runghc flag currently is -f /path/to/ghc, which tells runghc which GHC to use to run the program.

I don't see a bug logged at http://hackage.haskell.org/trac/ghc . Seems pretty lame to me. I'd suggest asking on irc #ghc, or the cvs-ghc mailing list.

Of the other Haskell compilers/interpreters, only nhc98 seems allow you to set the max stack size. Depending on your OS, nhc98 could be an option.

ja.
  • 4,245
  • 20
  • 22
2

I'm doing the same thing (Project Euler) and have been using ghc. The trick (thanks #haskell!) is to tell the executable to have more stack size rather than the compiler.

$ ghc -O2 -o 23 23.hs
$ ./23 +RTS -K128M
ale
  • 6,369
  • 7
  • 55
  • 65
1

Just compile it.

Problem123.hs:

module Main where
main = do
    print solution
solution = ...

Short and sweet command line:

ghc --make -O3 Problem123.hs
./Problem123

Final note: I'm not sure I would call them "scripts".

yfeldblum
  • 65,165
  • 12
  • 129
  • 169
  • 1
    Yeah, It's easy enough to compile using --make. However, it's even easier to hit R in TextMate on OS X and have the file executed with runhaskell. When you're hacking away and constantly changing things, it's just easier. – Gregory Higley Nov 09 '08 at 07:15
  • 1
    Scripting has always been one of the design goals of Haskell, and calling programs scripts is fairly common, for example: http://groups.google.com/group/comp.lang.functional/browse_thread/thread/5a6df7d9b550346f?hl=en – ja. Nov 10 '08 at 02:20