summaryrefslogtreecommitdiff
path: root/Example.hs
blob: a9f50aaab26c53775e84b6ccce6463c2e0403b14 (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
{-# LANGUAGE DeriveGeneric #-}

module Main where

import GHC.Generics
import Text.Megaparsec
import Coalpit

data RecTest = RecTest { a :: Maybe Int, b :: Maybe Double, c :: Maybe Int }
             deriving (Generic, Show)

instance ArgParser RecTest
instance ToArgs RecTest

data Foo = Bar Int
         | Baz Int
         | Qux (Maybe Int) (Maybe Int) RecTest (Maybe Double)
  deriving (Generic, Show)

instance ToArgs Foo
instance ArgParser Foo

main :: IO ()
main = do
  let val = Qux Nothing (Just 1) (RecTest Nothing (Just 2.3) Nothing) Nothing
      a = args val
  print val
  putStrLn a
  print $ parse (argParser :: Parser Foo) "test" a