Open Hrothen opened 9 years ago
A slightly simpler example:
data State = On | Off deriving (Data, Show, Typeable)
data Mode = Mode {state :: [State]} deriving (Show, Data, Typeable)
main = print =<< cmdArgs Mode{state = enum [[On], [Off]]}
And the smallest change that can fix it:
main = print =<< cmdArgs Mode{state = enum [[On] &= name "on", [Off] &= name "off"]}
So the problem is that enum
tries to guess at flag names based on the value in each of [On]
and [Off]
. It can guess the value from a constructor, but not a list. Since it can't guess the name it raises an exception. The ways round this are:
ignore
first or not) - but it should be doable in this case. However, it's not going to be possible in all cases.Tested by adding name
to the non-ignored flags in my example and it does work properly without needing to name an ignored argument.
Attempting to run the following minimal example given in the documentation for
enum
:results in the error message:
System.Console.CmdArgs.Implicit, unexpected no available name: ?
regardless of the flags passed to the executable.I've only tested this with GHC 7.10.1