Skip to content

Default Lists? #58

Description

@Chobbes

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions