Playing around with the ReadArgs package, it seems that it does not support single-argument situations.
{-# LANGUAGE ScopedTypeVariables #-}
import ReadArgs (readArgs)
main = do
(foo :: Int) <- readArgs
print foo
The error is (when using version 1.0):
No instance for (ReadArgs.ArgumentTuple Int)
arising from a use of `readArgs'
My question is twofold:
- How does
readArgswork? - How can that library be adjusted to allow it to work with a single argument as well?
N.B. version 1.1 of ReadArgs eliminates this “error”; see comments.
I don’t quite understand all of the extensions I needed to enable, but you could define an instance of
ReadArgs.ArgumentTuple a(even though it’s not really a semantically correct name) like this:Also, I’m not really sure if there are any problems with this instance, though it works for the example you presented. I would assume there’s a reason it’s missing from the library, but I may be wrong.
Update
After looking trying a few things out, to be sure they still work (like the following example), I’m fairly convinced this doesn’t cause any problems, so maybe it’s (or something similar) existance was just an oversight.