mirror of
https://github.com/Gabriella439/optparse-generic.git
synced 2024-11-22 21:48:54 +03:00
42c107bdae
closes #34
25 lines
653 B
Haskell
25 lines
653 B
Haskell
{-# LANGUAGE DataKinds #-}
|
|
{-# LANGUAGE DeriveGeneric #-}
|
|
{-# LANGUAGE FlexibleInstances #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# LANGUAGE StandaloneDeriving #-}
|
|
{-# LANGUAGE TypeOperators #-}
|
|
|
|
import Data.Coerce
|
|
import Options.Generic
|
|
|
|
data Options w = Options
|
|
{ a :: w ::: Int <?> "Int option -- must be divisible by 10"
|
|
, b :: w ::: Bool <?> "Bool option"
|
|
, c :: w ::: String <?> "String option"
|
|
} deriving Generic
|
|
|
|
instance ParseRecord (Options Wrapped)
|
|
deriving instance Show (Options Unwrapped)
|
|
|
|
main = do
|
|
(opts, help) <- unwrapWithHelp "unwrap-example"
|
|
if (a opts) `rem` 10 == 0
|
|
then print (opts :: Options Unwrapped)
|
|
else help
|