Why is numCapabilities a pure function?

Viewed 751

In the concurrency library GHC.Conc there is a function called numCapabilities. Its type is numCapabilities :: Int and it actually returns some number you passed by the command line flag (e.g. 5 if the options are +RTS -N 5).

However, getArgs (type: IO [String]) does essentially the same (it returns the unparsed non-runtime arguments) but isn't a pure function.

If the only excuse is that numCapabilities is often needed in pure code, in what way aren't other command line options not needed in pure code?

Am I something missing or is either numCapabilities a design flaw or am I allowed to write the following monster?

myGetArgs = unsafePerformIO getArgs
4 Answers
Related