How to increase stack size with runhaskell?

I am writing several one-time Haskell scripts to solve some of the problems of Project Euler . I really do not want to compile them because of the number of changes that I constantly have to make, but in some cases I found that I had run out of stack space.

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

 runhaskell +RTS -K5M -RTS Script.hs 

It never, never works (in any permutation I tried). The stack size always remains 8 388 608. This is crazy, and I did not find much help on Google.

Any suggestions? What am I doing wrong?

+9
haskell haskell-stack
Nov 08 '08 at 21:48
source share
3 answers

I assume you are using GHC. Chapter 4 of the User Guide for the recently released 6.10.1 says:

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

I do not see the error registered at http://hackage.haskell.org/trac/ghc . It seems to me very lame. I suggest asking for irC # ghc or the cvs-ghc mailing list.

Of the other Haskell compilers / interpreters, only nhc98 allows you to set the maximum stack size. Depending on your OS, nhc98 might be an option.

+8
Nov 09 '08 at 4:53
source share

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 will call them β€œscripts”.

+1
Nov 09 '08 at 4:59
source share

I do the same (Project Euler) and use ghc. The trick (thanks #haskell!) Is to tell the executable to be larger than the stack size, not the compiler.

 $ ghc -O2 -o 23 23.hs $ ./23 +RTS -K128M 
+1
Jan 10 '09 at 23:46
source share



All Articles