Haskell’s Runtime System Options

This post is just a quick comment about Haskell’s runtime system options. Most tutorials explain to give those via +RTS [options], e.g. here. But most of the time those “classic examples” run simple scripts without command line arguments. But this obviously conflicts if we want to have command line arguments too.

Luckily the Haskell runtime system is so nice to tell us what to do:

So here for completeness what most of these tutorials miss to mention: +RTS “opens” the backdoor to Haskell’s runtime system, but this door can be closed again, with -RTS!

So the rules are simple:

  1. The Haskell runtime system parses the command line first
  2. Everything after a +RTS until the end of the line or a -RTS is consumed by the runtime, everything else is forwarded to the application

So in our above example these two options do the trick:

This can also be read in the official documentation.