summaryrefslogtreecommitdiff
path: root/Example.hs
blob: 725f8ccb921df6bb3d403af0040574ac77a202a5 (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 :: Int, b :: Double }
             deriving (Generic, Show)

instance ArgParser RecTest
instance ToArgs RecTest

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

instance ToArgs Foo
instance ArgParser Foo

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