mirror of
https://github.com/Gabriella439/Haskell-Optparse-Generic-Library.git
synced 2024-11-23 13:57:59 +03:00
Add Sum
and Product
instance for ParseField
This commit is contained in:
parent
c094cfc879
commit
19e762ce86
@ -138,10 +138,16 @@ instance ParseField a => ParseField (Maybe a) where
|
||||
parseField = fmap optional parseField
|
||||
|
||||
instance ParseField a => ParseField (First a) where
|
||||
parseField = fmap (fmap mconcat . many . fmap pure) parseField
|
||||
parseField = fmap (fmap mconcat . many . fmap First) parseField
|
||||
|
||||
instance ParseField a => ParseField (Last a) where
|
||||
parseField = fmap (fmap mconcat . many . fmap pure) parseField
|
||||
parseField = fmap (fmap mconcat . many . fmap Last) parseField
|
||||
|
||||
instance (Num a, ParseField a) => ParseField (Sum a) where
|
||||
parseField = fmap (fmap mconcat . many . fmap Sum) parseField
|
||||
|
||||
instance (Num a, ParseField a) => ParseField (Product a) where
|
||||
parseField = fmap (fmap mconcat . many . fmap Product) parseField
|
||||
|
||||
instance ParseField a => ParseField [a] where
|
||||
parseField = fmap many parseField
|
||||
|
Loading…
Reference in New Issue
Block a user