summaryrefslogtreecommitdiff
path: root/Example.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Example.hs')
-rw-r--r--Example.hs27
1 files changed, 8 insertions, 19 deletions
diff --git a/Example.hs b/Example.hs
index a1af925..9fb9e0b 100644
--- a/Example.hs
+++ b/Example.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
module Main where
import GHC.Generics
@@ -7,25 +7,16 @@ import Data.Proxy
data FooArgs = FooArgs { arg1 :: Int
, arg2 :: String
- } deriving (Generic, Show)
-instance ArgParser FooArgs
-instance ToArgs FooArgs
-instance ArgHelper FooArgs
+ } deriving (Show, Generic, Coalpit)
data FooBar = Foo FooArgs
| Bar
- deriving (Generic, Show)
-instance ArgParser FooBar
-instance ToArgs FooBar
-instance ArgHelper FooBar
+ deriving (Show, Generic, Coalpit)
data Input = Input { something :: Maybe String
, fooBar :: Maybe FooBar
, fooBar2 :: FooBar
- } deriving (Generic, Show)
-instance ArgParser Input
-instance ToArgs Input
-instance ArgHelper Input
+ } deriving (Show, Generic, Coalpit)
main :: IO ()
main = do
@@ -39,18 +30,16 @@ main = do
print (fromArgs defOpt args :: Either String Input)
data Test = Test { foo :: [Int], bar :: Maybe String }
- deriving (Generic, Show)
-
-instance ArgParser Test
-instance ToArgs Test
-instance ArgHelper Test
+ deriving (Show, Generic, Coalpit)
help :: IO ()
help = do
mapM_ (\(o, x, y) -> print o >> print x >> putStrLn y) $
[ let opts = defOpt { alwaysUseSelName = ausn
, omitNamedOptions = ono }
- in ((ausn, ono), toArgs opts (Test [] vals), argHelper opts [] (Proxy :: Proxy Test))
+ in ( (ausn, ono)
+ , toArgs opts (Test [] vals)
+ , argHelper opts [] (Proxy :: Proxy Test))
| ausn <- [True, False]
, ono <- [True, False]
, vals <- [Just "a string", Nothing]]