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

Example combining <!> default values and <?> documented fields? #75

Open
austinvhuang opened this issue Aug 15, 2020 · 1 comment
Open

Comments

@austinvhuang
Copy link

The docs have examples using <?> for documentation and an example using <!> for default values. It's not obvious (to me at least) how to use them together. Could you provide an example of this?

@Gabriella439
Copy link
Owner

Here is an example of using both:

{-# LANGUAGE DataKinds          #-}
{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE FlexibleInstances  #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators      #-}

import Options.Generic

data Example w = Example
    { foo :: w ::: (Int    <?> "Documentation for the foo flag" <!> "1"  )
    , bar :: w ::: (Double <?> "Documentation for the bar flag" <!> "2.0")
    } deriving (Generic)

instance ParseRecord (Example Wrapped)
deriving instance Show (Example Unwrapped)

main = do
    x <- unwrapRecord "Test program"

    print (x :: Example Unwrapped)

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

2 participants