blob: 4784aa23497c139786ff74f6a28d210015a94821 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
{-# LANGUAGE DeriveGeneric #-}
module Main where
import GHC.Generics
import Coalpit
data FooArgs = FooArgs { arg1 :: Int
, arg2 :: String
} deriving (Generic, Show)
instance ArgParser FooArgs
instance ToArgs FooArgs
data FooBar = Foo FooArgs
| Bar
deriving (Generic, Show)
instance ArgParser FooBar
instance ToArgs FooBar
data Input = Input { something :: Maybe String
, fooBar :: Maybe FooBar
, fooBar2 :: FooBar
} deriving (Generic, Show)
instance ArgParser Input
instance ToArgs Input
main :: IO ()
main = do
let val = Input { something = Nothing
, fooBar = Just (Foo FooArgs { arg1 = 1
, arg2 = "a string"})
, fooBar2 = Bar}
args = toArgs defMod val
print val
print args
print (fromArgs defMod args :: Either String Input)
|