954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Haskell command-line args

Hello, I have an issue using Haskell's Command-Line args functionality. I'm writing a Typechecker for my parser and I need to be able to tell my program via command-line arguments that I can have at most x errors reported where x is:

./typechecker --number-of-errors=x test.cl

This is the run-statement I use after I have compiled my Haskell program using:
make typechecker

I handle this in Main.hs, you can find the relevant code here:

main :: IO ()
main = do
  
  filenames <- getArgs  -- get the command line arguments
  when (null filenames) (fail "No file name")

  mapM_ (\f -> processFile f `catch` (const (return ()))) filenames


I am confused on how to implement capturing the "--" flag and on top of this, how to capture whatever value x will be. I'm not asking you to complete this for me, I'm just looking for resources to use to help me out. I can't seem to locate the proper modules to include that provide functions for doing this. Any guidance is appreciated!

ckwolfe
Newbie Poster
10 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

The proper functions are the basic string handling functions. It's called programming. There might be some command line parsing library but it is so trivial to support this feature yourself.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You