optparse-generic 1.4.8 → 1.4.9
raw patch · 6 files changed
+75/−6 lines, 6 filesdep +optparse-genericnew-component:exe:optparse-generic-example-unwrap-optionsnew-component:exe:optparse-generic-example-unwrap-with-help
Dependencies added: optparse-generic
Files
- CHANGELOG.md +4/−0
- LICENSE +2/−2
- examples/unwrap-options.hs +22/−0
- examples/unwrap-with-help.hs +24/−0
- optparse-generic.cabal +22/−4
- src/Options/Generic.hs +1/−0
CHANGELOG.md view
@@ -1,3 +1,7 @@+1.4.9++* [Add `Data` instance for `Unwrapped`](https://github.com/Gabriella439/optparse-generic/pull/100)+ 1.4.8 * [Improve handling of `NonEmpty`](https://github.com/Gabriella439/optparse-generic/pull/98)
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2016 Gabriel Gonzalez+Copyright (c) 2016 Gabriella Gonzalez All rights reserved. Redistribution and use in source and binary forms, with or without modification,@@ -8,7 +8,7 @@ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.- * Neither the name of Gabriel Gonzalez nor the names of other contributors+ * Neither the name of Gabriella Gonzalez nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+ examples/unwrap-options.hs view
@@ -0,0 +1,22 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE TypeOperators #-}++import Options.Generic++data Options w = Options+ { a :: w ::: Int <?> "Int option"+ , b :: w ::: Bool <?> "Bool option"+ , c :: w ::: String <?> "String option"+ } deriving Generic++instance ParseRecord (Options Wrapped)+deriving instance Show (Options Unwrapped)++main :: IO ()+main = do+ opts <- unwrapRecord "unwrap-example"+ print (opts :: Options Unwrapped)
+ examples/unwrap-with-help.hs view
@@ -0,0 +1,24 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE TypeOperators #-}++import Options.Generic++data Options w = Options+ { a :: w ::: Int <?> "Int option -- must be divisible by 10"+ , b :: w ::: Bool <?> "Bool option"+ , c :: w ::: String <?> "String option"+ } deriving Generic++instance ParseRecord (Options Wrapped)+deriving instance Show (Options Unwrapped)++main :: IO ()+main = do+ (opts, help) <- unwrapWithHelp "unwrap-example"+ if (a opts) `rem` 10 == 0+ then print (opts :: Options Unwrapped)+ else help
optparse-generic.cabal view
@@ -1,14 +1,14 @@ Name: optparse-generic-Version: 1.4.8+Version: 1.4.9 Cabal-Version: >=1.10 Build-Type: Simple License: BSD3 License-File: LICENSE Copyright: 2016 Gabriella Gonzalez Author: Gabriella Gonzalez-Maintainer: Gabriel439@gmail.com+Maintainer: GenuineGabriella@gmail.com Tested-With: GHC == 7.8.4, GHC == 7.10.2, GHC == 8.0.1-Bug-Reports: https://github.com/Gabriel439/Haskell-Optparse-Generic-Library/issues+Bug-Reports: https://github.com/Gabriella439/Haskell-Optparse-Generic-Library/issues Synopsis: Auto-generate a command-line parser for your datatype Description: This library auto-generates an @optparse-applicative@-compatible @Parser@ from any data type that derives the @Generic@ interface.@@ -19,7 +19,7 @@ Extra-Source-Files: CHANGELOG.md Source-Repository head Type: git- Location: https://github.com/Gabriel439/Haskell-Optparse-Generic-Library+ Location: https://github.com/Gabriella439/Haskell-Optparse-Generic-Library Library Hs-Source-Dirs: src@@ -47,3 +47,21 @@ Exposed-Modules: Options.Generic GHC-Options: -Wall Default-Language: Haskell2010++executable optparse-generic-example-unwrap-options+ ghc-options: -Wall+ default-language: Haskell2010+ hs-source-dirs: examples+ main-is: unwrap-options.hs+ build-depends:+ base >= 4.7 && <5,+ optparse-generic++executable optparse-generic-example-unwrap-with-help+ ghc-options: -Wall+ default-language: Haskell2010+ hs-source-dirs: examples+ main-is: unwrap-with-help.hs+ build-depends:+ base >= 4.7 && <5,+ optparse-generic
src/Options/Generic.hs view
@@ -1227,6 +1227,7 @@ -- | Flag to unwrap fields annotated using '(<?>)' data Unwrapped+ deriving (Data) -- | Constraint for types whose fields can be unwrapped type Unwrappable f = (Generic (f Wrapped), Generic (f Unwrapped), GenericUnwrappable (Rep (f Wrapped)) (Rep (f Unwrapped)))