cmdargs
cmdargs copied to clipboard
Using the `explicit` annotation (with `System.Console.CmdArgs.Implicit`) isn't honored
I simply switched compiler versions from GHC 7.6.3 to GHC 7.8.4, using the same cmdargs version, 0.10.13 and suddenly invoking --help on a subcommand reported a flag named --cmddatabaseurl instead of --database-url. The record field is cmdDatabaseUrl :: String.
I will try to come up with a minimal example soon.
Can you please try setting {-# OPTIONS_GHC -fno-cse #-} at the top of the file - does that fix it?
Yes it does. I guess I'll use it until I convert everything to the Explicit variant.
Thanks for the quick reply and the workaround. I now think I've seen the suggestion elsewhere, maybe by you on reddit or twitter or in the doc. Thanks!
It's worth noting that -fno-cse doesn't help if the "config" type has strict fields, in which case the annotations are ignored again. For example, using the README's first example
{-# LANGUAGE DeriveDataTypeable #-}
{-# OPTIONS_GHC -fno-cse #-}
import System.Console.CmdArgs.Implicit
data Sample = Sample {hello :: !String} deriving (Show, Data, Typeable)
sample = Sample {
hello = def &= help "World argument" &= opt "world"
} &= summary "Sample v1"
main = print =<< cmdArgs sample
$ runghc Main.hs --help
Main.hs: System.Console.CmdArgs.Implicit, unexpected mode: FlagOptional "world"