Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the explicit annotation (with System.Console.CmdArgs.Implicit) isn't honored #37

Open
noteed opened this issue Nov 25, 2015 · 3 comments

Comments

@noteed
Copy link

noteed commented Nov 25, 2015

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.

@ndmitchell
Copy link
Owner

Can you please try setting {-# OPTIONS_GHC -fno-cse #-} at the top of the file - does that fix it?

@noteed
Copy link
Author

noteed commented Nov 25, 2015

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!

@gridaphobe
Copy link

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants