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

Default Lists? #58

Open
Chobbes opened this issue Jun 3, 2019 · 0 comments
Open

Default Lists? #58

Chobbes opened this issue Jun 3, 2019 · 0 comments

Comments

@Chobbes
Copy link

Chobbes commented Jun 3, 2019

Say I have command line arguments, and one of the things that I want to accept is a list of arguments. Let's just use the example from here:

https://zuttobenkyou.wordpress.com/2011/04/19/haskell-using-cmdargs-single-and-multi-mode/

So, I have a list of formats, and I might want to specify several of them.

data Format     = Text
                | TeX
                | HTML
                | FNone
    deriving (Data, Typeable, Show, Eq)

data MyOptions = MyOptions
    { ...
    , format :: [Format]
    , ...
    } deriving (Data, Typeable, Show, Eq)

myProgOpts = MyOptions
    { ...
    , format = [] &= help "format of output"
    , ...
    }

This seems to work well, but when format is, say [TeX] by default (instead of the empty list) I would expect the behavior to be [TeX] when no argument is passed in, but if I do something like... -f Text -f HTML I would expect to get [Text, HTML]. Instead you get a list with [Tex, Text, HTML].

Is this the expected behaviour? Is there any way to get my desired behaviour of [Text, HTML]?

Thanks in advance!

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

1 participant