mirror of
https://github.com/Gabriella439/Haskell-Optparse-Generic-Library.git
synced 2024-11-23 13:57:59 +03:00
Adds ParseFields/ParseRecord instances for NonEmpty
This commit is contained in:
parent
08bfce911b
commit
c78565b058
@ -30,7 +30,9 @@ Library
|
|||||||
optparse-applicative >= 0.11.0 && < 0.14,
|
optparse-applicative >= 0.11.0 && < 0.14,
|
||||||
time >= 1.5 && < 1.7 ,
|
time >= 1.5 && < 1.7 ,
|
||||||
void < 0.8 ,
|
void < 0.8 ,
|
||||||
bytestring < 0.11
|
bytestring < 0.11,
|
||||||
|
semigroups >= 0.18.1
|
||||||
|
|
||||||
if impl(ghc < 7.8)
|
if impl(ghc < 7.8)
|
||||||
Build-Depends:
|
Build-Depends:
|
||||||
singletons >= 0.10.0 && < 1.0 ,
|
singletons >= 0.10.0 && < 1.0 ,
|
||||||
|
@ -235,6 +235,7 @@ import Control.Applicative
|
|||||||
import Control.Monad.IO.Class (MonadIO(..))
|
import Control.Monad.IO.Class (MonadIO(..))
|
||||||
import Data.Char (toLower, toUpper)
|
import Data.Char (toLower, toUpper)
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
|
import Data.List.NonEmpty (NonEmpty((:|)))
|
||||||
import Data.Proxy
|
import Data.Proxy
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import Data.Typeable (Typeable)
|
import Data.Typeable (Typeable)
|
||||||
@ -476,6 +477,9 @@ instance (Num a, ParseField a) => ParseFields (Product a) where
|
|||||||
instance ParseField a => ParseFields [a] where
|
instance ParseField a => ParseFields [a] where
|
||||||
parseFields = parseListOfField
|
parseFields = parseListOfField
|
||||||
|
|
||||||
|
instance ParseField a => ParseFields (NonEmpty a) where
|
||||||
|
parseFields h m = (:|) <$> parseField h m <*> parseListOfField h m
|
||||||
|
|
||||||
{-| Use this to annotate a field with a type-level string (i.e. a `Symbol`)
|
{-| Use this to annotate a field with a type-level string (i.e. a `Symbol`)
|
||||||
representing the help description for that field:
|
representing the help description for that field:
|
||||||
|
|
||||||
@ -589,6 +593,9 @@ instance (Num a, ParseField a) => ParseRecord (Product a) where
|
|||||||
instance ParseField a => ParseRecord [a] where
|
instance ParseField a => ParseRecord [a] where
|
||||||
parseRecord = fmap getOnly parseRecord
|
parseRecord = fmap getOnly parseRecord
|
||||||
|
|
||||||
|
instance ParseField a => ParseRecord (NonEmpty a) where
|
||||||
|
parseRecord = fmap getOnly parseRecord
|
||||||
|
|
||||||
instance (ParseFields a, ParseFields b) => ParseRecord (a, b)
|
instance (ParseFields a, ParseFields b) => ParseRecord (a, b)
|
||||||
instance (ParseFields a, ParseFields b, ParseFields c) => ParseRecord (a, b, c)
|
instance (ParseFields a, ParseFields b, ParseFields c) => ParseRecord (a, b, c)
|
||||||
instance (ParseFields a, ParseFields b, ParseFields c, ParseFields d) => ParseRecord (a, b, c, d)
|
instance (ParseFields a, ParseFields b, ParseFields c, ParseFields d) => ParseRecord (a, b, c, d)
|
||||||
|
Loading…
Reference in New Issue
Block a user