summaryrefslogtreecommitdiff
path: root/Example.hs
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-12-20 10:12:52 +0300
committerdefanor <defanor@uberspace.net>2017-12-20 10:12:52 +0300
commitb2435e1e37b9def481761a00c704d280ef2deb96 (patch)
tree165aa7466248700d9820eaabb3e507ac06225822 /Example.hs
parent3350f07b88a4628d83abaf9eaea2f0dfc2e44edf (diff)
Remove Coalpit.IO
Better to focus on printing and parsing here, at least for now; besides, pipes are nice, but some may prefer other methods. The code is moved into an example instead.
Diffstat (limited to 'Example.hs')
-rw-r--r--Example.hs45
1 files changed, 0 insertions, 45 deletions
diff --git a/Example.hs b/Example.hs
deleted file mode 100644
index a08730d..0000000
--- a/Example.hs
+++ /dev/null
@@ -1,45 +0,0 @@
-{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
-module Main where
-
-import GHC.Generics
-import Coalpit
-import Data.Proxy
-
-data FooArgs = FooArgs { arg1 :: Int
- , arg2 :: String
- } deriving (Show, Generic, Coalpit)
-
-data FooBar = Foo FooArgs
- | Bar
- deriving (Show, Generic, Coalpit)
-
-data Input = Input { something :: Maybe String
- , fooBar :: Maybe FooBar
- , fooBar2 :: FooBar
- } deriving (Show, Generic, Coalpit)
-
-main :: IO ()
-main = do
- let val = Input { something = Nothing
- , fooBar = Just (Foo FooArgs { arg1 = 1
- , arg2 = "a string"})
- , fooBar2 = Bar}
- args = toArgs defOpt val
- print val
- print args
- print (fromArgs defOpt args :: Either String Input)
-
-data Test = Test { foo :: [Int], bar :: Maybe String }
- deriving (Show, Generic, Coalpit)
-
-help :: IO ()
-help = do
- mapM_ (\(o, x, y) -> print o >> putStrLn x >> putStrLn y) $
- [ let opts = defOpt { alwaysUseSelName = ausn
- , omitNamedOptions = ono }
- in ( (ausn, ono)
- , showDSV opts [Test [1,2,3] vals]
- , argHelper opts [] (Proxy :: Proxy Test))
- | ausn <- [True, False]
- , ono <- [True, False]
- , vals <- [Just "a string", Nothing]]